feat: implement reference capture mode.

This commit is contained in:
2026-05-05 11:20:53 +04:00
parent faf1715ee3
commit 708f63a00d
3 changed files with 43 additions and 7 deletions

View File

@@ -3,6 +3,7 @@
#include <gnu_argument_convention.hpp>
#include <macros.h>
#include <iostream>
#include <parser_v2.hpp>
#include <string>
#include <traits.hpp>
@@ -44,6 +45,8 @@ class parser_trait<std::vector<T>> {
>;
};
using namespace argument_parser::v2::flags;
auto main() -> int {
argument_parser::v2::parser parser(false);
@@ -63,6 +66,12 @@ auto main() -> int {
.reference(captured_value)
.build(parser);
// parser.add_argument<int>({
// {ShortArgument, "c"},
// {HelpText, "capture count"},
// {Reference, &captured_value},
// });
argument::start()
.short_argument("q")
.help_text("Store a boolean flag.")
@@ -95,5 +104,7 @@ auto main() -> int {
&argument_parser::conventions::gnu_argument_convention
});
std::cout << "captured value: " << captured_value << '\n';
return 0;
}