From 753b64c8263f0c310e4baa786ff42050e2f66cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Lundeg=C3=A5rd=20Kylander?= Date: Sat, 11 Jul 2026 22:11:39 +0200 Subject: [PATCH] Add variation of 'with' that extracts the trailing string and feeds it back into the callback --- core-library/views/command-line-args-view.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core-library/views/command-line-args-view.h b/core-library/views/command-line-args-view.h index 35c8906..12f8a3e 100644 --- a/core-library/views/command-line-args-view.h +++ b/core-library/views/command-line-args-view.h @@ -1,4 +1,6 @@ #pragma once +#include "core-library/traits/function-traits.h" + #include #include #include @@ -22,6 +24,17 @@ public: std::invoke(std::forward(function)); } + template + requires core::callable_with_argument_converted + void with(std::string_view arg_to_match_view, F&& function) const + { + if (m_arg_view.starts_with(arg_to_match_view)) + { + const std::string_view value_part = m_arg_view.substr(arg_to_match_view.size()); + std::invoke(std::forward(function), core::first_argument_type_t{value_part}); + } + } + private: std::string_view m_arg_view; std::span m_modifiers;