refactor(argument_parser): improve argument handling and cleanup code

- Add new template method for argument addition with type
- Handle optional values more safely in get_optional
- Remove commented test code from main.cpp
This commit is contained in:
2025-10-06 04:09:15 +04:00
parent 8437a00c6b
commit d30105abe1
2 changed files with 10 additions and 8 deletions

View File

@@ -105,10 +105,9 @@ auto make_grep_action(argument_parser::base_parser& parser) {
}
int main() {
// std::vector<std::string> fake_args = { "-g", "add", "-f", "src/main.cpp", "-ep", "1,2" };
// auto parser = argument_parser::fake_parser{"test", std::move(fake_args)};
auto parser = argument_parser::parser{};
auto [file, grep] = make_grep_action(parser);
parser.add_argument("e", "echo", "echoes given variable", echo, false);
parser.add_argument("ep", "echo-point", "echoes given point", echo_point, false);
parser.add_argument("f", "file", "File to grep, required only if using grep", file, false);