mirror of
https://github.com/sametersoylu/argument-parser.git
synced 2026-05-28 20:08:10 +00:00
feat: implement reference capture mode.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user