Skip to content

Commit

Permalink
feat: hide argv span construction
Browse files Browse the repository at this point in the history
  • Loading branch information
ggabriel96 committed Feb 26, 2025
1 parent 5931776 commit c686370
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main(int argc, char const *argv[]) {
// auto const r = FindArg(p.args, [](auto const view) { return view.name == "platform"; });
// std::print("{}\n", r->name);

auto const map = parse(p, std::span<char const *>{argv, static_cast<size_t>(argc)});
auto const map = parse(p, argc, argv);
std::print("\nargs map (size {}):\n", map.args.size());
std::print("name: {}\n", map.get<"name">());
std::print("platform: {}\n", map.get<"platform">());
Expand Down
4 changes: 3 additions & 1 deletion include/experimental/parsing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ template <fixed_string... Names, typename... Types>
ArgParser(Program<StringList<Names...>, TypeList<Types...>> const &program) -> ArgParser<StringList<Names...>, TypeList<Types...>>;

template <fixed_string... Names, typename... Types>
auto parse(Program<StringList<Names...>, TypeList<Types...>> const &program, std::span<char const *> args) {
auto parse(Program<StringList<Names...>, TypeList<Types...>> const &program, int argc, char const *argv[]) {
auto const args = std::span<char const *>{argv, static_cast<std::size_t>(argc)};

auto parser = ArgParser(program);
auto const view = parser.get_args_view(args);
view.print_debug();
Expand Down

0 comments on commit c686370

Please sign in to comment.