{"id":15033301,"url":"https://github.com/taywee/args","last_synced_at":"2025-05-14T03:06:49.539Z","repository":{"id":43396031,"uuid":"57257111","full_name":"Taywee/args","owner":"Taywee","description":"  A simple header-only C++ argument parser library. Supposed to be flexible and powerful, and attempts to be compatible with the functionality of the Python standard argparse library (though not necessarily the API).","archived":false,"fork":false,"pushed_at":"2025-04-04T04:11:26.000Z","size":2970,"stargazers_count":1484,"open_issues_count":16,"forks_count":165,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-04-05T09:02:54.669Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Taywee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-28T00:10:18.000Z","updated_at":"2025-04-04T20:22:21.000Z","dependencies_parsed_at":"2024-01-31T09:02:21.984Z","dependency_job_id":"9a3e96b5-750a-40e6-ae4e-83a1a994baad","html_url":"https://github.com/Taywee/args","commit_stats":{"total_commits":242,"total_committers":27,"mean_commits":8.962962962962964,"dds":0.5371900826446281,"last_synced_commit":"30cbfdc69ab65bf9df78b811a9ae19a923ae84c9"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taywee%2Fargs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taywee%2Fargs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taywee%2Fargs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taywee%2Fargs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Taywee","download_url":"https://codeload.github.com/Taywee/args/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248564535,"owners_count":21125408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T20:20:39.534Z","updated_at":"2025-04-12T11:45:38.821Z","avatar_url":"https://github.com/Taywee.png","language":"C++","readme":"# args\n\n**This library is considered feature-complete by its creator.  It will still\nreceive bug fixes, and good pull requests will be accepted, but no new major\nfunctionality or API changes will be added to this codebase.**\n\n[![Cpp Standard](https://img.shields.io/badge/C%2B%2B-11-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B11)\n[![Travis status](https://travis-ci.org/Taywee/args.svg?branch=master)](https://travis-ci.org/Taywee/args)\n[![AppVeyor status](https://ci.appveyor.com/api/projects/status/nlnlmpttdjlndyc2?svg=true)](https://ci.appveyor.com/project/Taywee/args)\n[![Coverage Status](https://coveralls.io/repos/github/Taywee/args/badge.svg?branch=master)](https://coveralls.io/github/Taywee/args?branch=master)\n[![Read the Docs](https://img.shields.io/readthedocs/pip.svg)](https://taywee.github.io/args)\n\nA simple, small, flexible, single-header C++11 argument parsing library.\n\nThis is designed to appear somewhat similar to Python's argparse, but in C++,\nwith static type checking, and hopefully a lot faster (also allowing fully\nnestable group logic, where Python's argparse does not).\n\nUTF-8 support is limited at best.  No normalization is performed, so non-ascii\ncharacters are very best kept out of flags, and combined glyphs are probably\ngoing to mess up help output if you use them.  Most UTF-8 necessary for\ninternationalization should work for most cases, though heavily combinatory UTF\nalphabets may wreak havoc.\n\nThis program is MIT-licensed, so you can use the header as-is with no\nrestrictions. I'd appreciate attribution in a README, Man page, or something if\nyou are feeling generous, but all that's required is that you don't remove the\nlicense and my name from the header of the args.hxx file in source\nredistributions (ie. don't pretend that you wrote it).  I do welcome additions\nand updates wherever you feel like contributing code.\n\nThe API documentation can be found at https://taywee.github.io/args\n\nThe code can be downloaded at https://github.com/Taywee/args\n\nThere are also somewhat extensive examples below.\n\nYou can find the complete test cases at\nhttps://github.com/Taywee/args/blob/master/test.cxx, which should very well\ndescribe the usage, as it's built to push the boundaries.\n\n# What does it do?\n\nIt:\n\n* Lets you handle flags, flag+value, and positional arguments simply and\n  elegantly, with the full help of static typechecking.\n* Allows you to use your own types in a pretty simple way.\n* Lets you use count flags, and lists of all argument-accepting types.\n* Allows full validation of groups of required arguments, though output isn't\n  pretty when something fails group validation. User validation functions are\n  accepted. Groups are fully nestable.\n* Generates pretty help for you, with some good tweakable parameters.\n* Lets you customize all prefixes and most separators, allowing you to create\n  an infinite number of different argument syntaxes.\n* Lets you parse, by default, any type that has a stream extractor operator for\n  it. If this doesn't work for your uses, you can supply a function and parse\n  the string yourself if you like.\n* Lets you decide not to allow separate-argument value flags or joined ones\n  (like disallowing `--foo bar`, requiring `--foo=bar`, or the inverse, or the\n  same for short options).\n* Allows you to create subparsers, to reuse arguments for multiple commands and\n  to refactor your command's logic to a function or lambda.\n* Allows one value flag to take a specific number of values (like `--foo first\n  second`, where --foo slurps both arguments).\n* Allows you to have value flags only optionally accept values.\n* Provides autocompletion for bash.\n\n# What does it not do?\n\nThere are tons of things this library does not do!\n\n## It will not ever:\n\n* Allow you to intermix multiple different prefix types (eg. `++foo` and\n  `--foo` in the same parser), though shortopt and longopt prefixes can be\n  different.\n* Allow you to make flags sensitive to order (like gnu find), or make them\n  sensitive to relative ordering with positionals.  The only orderings that are\n  order-sensitive are:\n    * Positionals relative to one-another\n    * List positionals or flag values to each of their own respective items\n* Allow you to use a positional list before any other positionals (the last\n  argument list will slurp all subsequent positional arguments).  The logic for\n  allowing this would be a lot more code than I'd like, and would make static\n  checking much more difficult, requiring us to sort std::string arguments and\n  pair them to positional arguments before assigning them, rather than what we\n  currently do, which is assigning them as we go for better simplicity and\n  speed.  The library doesn't stop you from trying, but the first positional\n  list will slurp in all following positionals\n\n# How do I install it?\n\n```shell\nsudo make install\n```\n\nOr, to install it somewhere special (default is `/usr/local`):\n\n```shell\nsudo make install DESTDIR=/opt/mydir\n```\n\nYou can also copy the file into your source tree, if you want to be absolutely\nsure you keep a stable API between projects.\n\nIf you prefer other installation methods, many standard ones are available and\nincluded, including CMake, conan, buck, and meson.  An example CMake file using\nargs is included in the examples directory.\n\n## I also want man pages.\n\n```shell\nmake doc/man\nsudo make installman\n```\n\nThis requires Doxygen\n\n## I want the doxygen documentation locally\n\n```shell\ndoxygen Doxyfile\n```\n\nYour docs are now in doc/html\n\n## How to depend on it using tipi.build?\n\nSimply add the following entry to your `.tipi/deps` file\n\n```json\n{\n    \"taywee/args\": { \"@\": \"6.4.1\" }\n}\n```\n\nYou can optionally remove the `@` section to *target HEAD* easily.\n\n# How do I use it?\n\nCreate an ArgumentParser, modify its attributes to fit your needs, add\narguments through regular argument objects (or create your own), and match them\nwith an args::Matcher object (check its construction details in the doxygen\ndocumentation.\n\nThen you can either call it with args::ArgumentParser::ParseCLI for the full\ncommand line with program name, or args::ArgumentParser::ParseArgs with\njust the arguments to be parsed.  The argument and group variables can then be\ninterpreted as a boolean to see if they've been matched.\n\nAll variables can be pulled (including the boolean match status for regular\nargs::Flag variables) with args::get.\n\n# Group validation is weird.  How do I get more helpful output for failed validation?\n\nThis is unfortunately not possible, given the power of the groups available.\nFor instance, if you have a group validation that works like \n`(A \u0026\u0026 B) || (C \u0026\u0026 (D XOR E))`, how is this library going to be able to\ndetermine what exactly when wrong when it fails?  It only knows that the\nentire expression evaluated false, not specifically what the user did wrong\n(and this is doubled over by the fact that validation operations are ordinary\nfunctions without any special meaning to the library).  As you are the only one\nwho understands the logic of your program, if you want useful group messages,\nyou have to catch the ValidationError as a special case and check your own\ngroups and spit out messages accordingly.\n\n# Is it developed with regression tests?\n\nYes.  tests.cxx in the git repository has a set of standard tests (which are\nstill relatively small in number, but I would welcome some expansion here), and\nthanks to Travis CI and AppVeyor, these tests run with every single push:\n\n```shell\n% make runtests\ng++ test.cxx -o test.o -I. -std=c++11 -O2 -c -MMD\ng++ -o test test.o -std=c++11 -O2\n./test\n===============================================================================\nAll tests passed (74 assertions in 15 test cases)\n\n%\n```\n\nThe testing library used is [Catch](https://github.com/philsquared/Catch).\n\n# Examples\n\nAll the code examples here will be complete code examples, with some output.\n\n## Simple example:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cargs.hxx\u003e\nint main(int argc, char **argv)\n{\n    args::ArgumentParser parser(\"This is a test program.\", \"This goes after the options.\");\n    args::HelpFlag help(parser, \"help\", \"Display this help menu\", {'h', \"help\"});\n    args::CompletionFlag completion(parser, {\"complete\"});\n    try\n    {\n        parser.ParseCLI(argc, argv);\n    }\n    catch (const args::Completion\u0026 e)\n    {\n        std::cout \u003c\u003c e.what();\n        return 0;\n    }\n    catch (const args::Help\u0026)\n    {\n        std::cout \u003c\u003c parser;\n        return 0;\n    }\n    catch (const args::ParseError\u0026 e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    return 0;\n}\n```\n\n```shell\n % ./test\n % ./test -h\n  ./test {OPTIONS} \n\n    This is a test program. \n\n  OPTIONS:\n\n      -h, --help         Display this help menu \n\n    This goes after the options. \n % \n```\n\n## Boolean flags, special group types, different matcher construction:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cargs.hxx\u003e\nint main(int argc, char **argv)\n{\n    args::ArgumentParser parser(\"This is a test program.\", \"This goes after the options.\");\n    args::Group group(parser, \"This group is all exclusive:\", args::Group::Validators::Xor);\n    args::Flag foo(group, \"foo\", \"The foo flag\", {'f', \"foo\"});\n    args::Flag bar(group, \"bar\", \"The bar flag\", {'b'});\n    args::Flag baz(group, \"baz\", \"The baz flag\", {\"baz\"});\n    try\n    {\n        parser.ParseCLI(argc, argv);\n    }\n    catch (args::Help)\n    {\n        std::cout \u003c\u003c parser;\n        return 0;\n    }\n    catch (args::ParseError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    catch (args::ValidationError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    if (foo) { std::cout \u003c\u003c \"foo\" \u003c\u003c std::endl; }\n    if (bar) { std::cout \u003c\u003c \"bar\" \u003c\u003c std::endl; }\n    if (baz) { std::cout \u003c\u003c \"baz\" \u003c\u003c std::endl; }\n    return 0;\n}\n```\n\n```shell\n % ./test   \nGroup validation failed somewhere!\n  ./test {OPTIONS} \n\n    This is a test program. \n\n  OPTIONS:\n\n                         This group is all exclusive:\n        -f, --foo          The foo flag \n        -b                 The bar flag \n        --baz              The baz flag \n\n    This goes after the options. \n % ./test -f\nfoo\n % ./test --foo\nfoo\n % ./test --foo -f\nfoo\n % ./test -b      \nbar\n % ./test --baz\nbaz\n % ./test --baz -f\nGroup validation failed somewhere!\n  ./test {OPTIONS} \n\n    This is a test program. \n...\n % ./test --baz -fb\nGroup validation failed somewhere!\n  ./test {OPTIONS} \n...\n % \n```\n\n## Argument flags, Positional arguments, lists\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cargs.hxx\u003e\nint main(int argc, char **argv)\n{\n    args::ArgumentParser parser(\"This is a test program.\", \"This goes after the options.\");\n    args::HelpFlag help(parser, \"help\", \"Display this help menu\", {'h', \"help\"});\n    args::ValueFlag\u003cint\u003e integer(parser, \"integer\", \"The integer flag\", {'i'});\n    args::ValueFlagList\u003cchar\u003e characters(parser, \"characters\", \"The character flag\", {'c'});\n    args::Positional\u003cstd::string\u003e foo(parser, \"foo\", \"The foo position\");\n    args::PositionalList\u003cdouble\u003e numbers(parser, \"numbers\", \"The numbers position list\");\n    try\n    {\n        parser.ParseCLI(argc, argv);\n    }\n    catch (args::Help)\n    {\n        std::cout \u003c\u003c parser;\n        return 0;\n    }\n    catch (args::ParseError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    catch (args::ValidationError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    if (integer) { std::cout \u003c\u003c \"i: \" \u003c\u003c args::get(integer) \u003c\u003c std::endl; }\n    if (characters) { for (const auto ch: args::get(characters)) { std::cout \u003c\u003c \"c: \" \u003c\u003c ch \u003c\u003c std::endl; } }\n    if (foo) { std::cout \u003c\u003c \"f: \" \u003c\u003c args::get(foo) \u003c\u003c std::endl; }\n    if (numbers) { for (const auto nm: args::get(numbers)) { std::cout \u003c\u003c \"n: \" \u003c\u003c nm \u003c\u003c std::endl; } }\n    return 0;\n}\n```\n\n```shell\n% ./test -h\n  ./test {OPTIONS} [foo] [numbers...] \n\n    This is a test program. \n\n  OPTIONS:\n\n      -h, --help         Display this help menu \n      -i integer         The integer flag \n      -c characters      The character flag \n      foo                The foo position \n      numbers            The numbers position list \n      \"--\" can be used to terminate flag options and force all following\n      arguments to be treated as positional options \n\n    This goes after the options. \n % ./test -i 5\ni: 5\n % ./test -i 5.2\nArgument 'integer' received invalid value type '5.2'\n  ./test {OPTIONS} [foo] [numbers...] \n % ./test -c 1 -c 2 -c 3\nc: 1\nc: 2\nc: 3\n % \n % ./test 1 2 3 4 5 6 7 8 9\nf: 1\nn: 2\nn: 3\nn: 4\nn: 5\nn: 6\nn: 7\nn: 8\nn: 9\n % ./test 1 2 3 4 5 6 7 8 9 a\nArgument 'numbers' received invalid value type 'a'\n  ./test {OPTIONS} [foo] [numbers...] \n\n    This is a test program. \n...\n```\n\n## Commands\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cargs.hxx\u003e\nint main(int argc, char **argv)\n{\n    args::ArgumentParser p(\"git-like parser\");\n    args::Group commands(p, \"commands\");\n    args::Command add(commands, \"add\", \"add file contents to the index\");\n    args::Command commit(commands, \"commit\", \"record changes to the repository\");\n    args::Group arguments(p, \"arguments\", args::Group::Validators::DontCare, args::Options::Global);\n    args::ValueFlag\u003cstd::string\u003e gitdir(arguments, \"path\", \"\", {\"git-dir\"});\n    args::HelpFlag h(arguments, \"help\", \"help\", {'h', \"help\"});\n    args::PositionalList\u003cstd::string\u003e pathsList(arguments, \"paths\", \"files to commit\");\n\n    try\n    {\n        p.ParseCLI(argc, argv);\n        if (add)\n        {\n            std::cout \u003c\u003c \"Add\";\n        }\n        else\n        {\n            std::cout \u003c\u003c \"Commit\";\n        }\n\n        for (auto \u0026\u0026path : pathsList)\n        {\n            std::cout \u003c\u003c ' ' \u003c\u003c path;\n        }\n\n        std::cout \u003c\u003c std::endl;\n    }\n    catch (args::Help)\n    {\n        std::cout \u003c\u003c p;\n    }\n    catch (args::Error\u0026 e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl \u003c\u003c p;\n        return 1;\n    }\n    return 0;\n}\n```\n\n```shell\n% ./test -h\n  ./test COMMAND [paths...] {OPTIONS}\n\n    git-like parser\n\n  OPTIONS:\n\n      commands\n        add                               add file contents to the index\n        commit                            record changes to the repository\n      arguments\n        --git-dir=[path]\n        -h, --help                        help\n        paths...                          files\n      \"--\" can be used to terminate flag options and force all following\n      arguments to be treated as positional options\n\n% ./test add 1 2\nAdd 1 2\n```\n\n## Refactoring commands\n\n```cpp\n#include \u003ciostream\u003e\n#include \"args.hxx\"\n\nargs::Group arguments(\"arguments\");\nargs::ValueFlag\u003cstd::string\u003e gitdir(arguments, \"path\", \"\", {\"git-dir\"});\nargs::HelpFlag h(arguments, \"help\", \"help\", {'h', \"help\"});\nargs::PositionalList\u003cstd::string\u003e pathsList(arguments, \"paths\", \"files to commit\");\n\nvoid CommitCommand(args::Subparser \u0026parser)\n{\n    args::ValueFlag\u003cstd::string\u003e message(parser, \"MESSAGE\", \"commit message\", {'m'});\n    parser.Parse();\n\n    std::cout \u003c\u003c \"Commit\";\n\n    for (auto \u0026\u0026path : pathsList)\n    {\n        std::cout \u003c\u003c ' ' \u003c\u003c path;\n    }\n\n    std::cout \u003c\u003c std::endl;\n\n    if (message)\n    {\n        std::cout \u003c\u003c \"message: \" \u003c\u003c args::get(message) \u003c\u003c std::endl;\n    }\n}\n\nint main(int argc, const char **argv)\n{\n    args::ArgumentParser p(\"git-like parser\");\n    args::Group commands(p, \"commands\");\n    args::Command add(commands, \"add\", \"add file contents to the index\", [\u0026](args::Subparser \u0026parser)\n    {\n        parser.Parse();\n        std::cout \u003c\u003c \"Add\";\n\n        for (auto \u0026\u0026path : pathsList)\n        {\n            std::cout \u003c\u003c ' ' \u003c\u003c path;\n        }\n\n        std::cout \u003c\u003c std::endl;\n    });\n\n    args::Command commit(commands, \"commit\", \"record changes to the repository\", \u0026CommitCommand);\n    args::GlobalOptions globals(p, arguments);\n\n    try\n    {\n        p.ParseCLI(argc, argv);\n    }\n    catch (args::Help)\n    {\n        std::cout \u003c\u003c p;\n    }\n    catch (args::Error\u0026 e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl \u003c\u003c p;\n        return 1;\n    }\n    return 0;\n}\n```\n\n```shell\n% ./test -h\n  ./test COMMAND [paths...] {OPTIONS}\n\n    git-like parser\n\n  OPTIONS:\n\n      commands\n        add                               add file contents to the index\n        commit                            record changes to the repository\n      arguments\n        --git-dir=[path]\n        -h, --help                        help\n        paths...                          files\n      \"--\" can be used to terminate flag options and force all following\n      arguments to be treated as positional options\n\n% ./test add 1 2\nAdd 1 2\n\n% ./test commit -m \"my commit message\" 1 2\nCommit 1 2\nmessage: my commit message\n```\n\n# Custom type parsers (here we use std::tuple)\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003ctuple\u003e\n\nstd::istream\u0026 operator\u003e\u003e(std::istream\u0026 is, std::tuple\u003cint, int\u003e\u0026 ints)\n{\n    is \u003e\u003e std::get\u003c0\u003e(ints);\n    is.get();\n    is \u003e\u003e std::get\u003c1\u003e(ints);\n    return is;\n}\n\n#include \u003cargs.hxx\u003e\n\nstruct DoublesReader\n{\n    void operator()(const std::string \u0026name, const std::string \u0026value, std::tuple\u003cdouble, double\u003e \u0026destination)\n    {\n        size_t commapos = 0;\n        std::get\u003c0\u003e(destination) = std::stod(value, \u0026commapos);\n        std::get\u003c1\u003e(destination) = std::stod(std::string(value, commapos + 1));\n    }\n};\n\nint main(int argc, char **argv)\n{\n    args::ArgumentParser parser(\"This is a test program.\");\n    args::Positional\u003cstd::tuple\u003cint, int\u003e\u003e ints(parser, \"INTS\", \"This takes a pair of integers.\");\n    args::Positional\u003cstd::tuple\u003cdouble, double\u003e, DoublesReader\u003e doubles(parser, \"DOUBLES\", \"This takes a pair of doubles.\");\n    try\n    {\n        parser.ParseCLI(argc, argv);\n    }\n    catch (args::Help)\n    {\n        std::cout \u003c\u003c parser;\n        return 0;\n    }\n    catch (args::ParseError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    if (ints)\n    {\n        std::cout \u003c\u003c \"ints found: \" \u003c\u003c std::get\u003c0\u003e(args::get(ints)) \u003c\u003c \" and \" \u003c\u003c std::get\u003c1\u003e(args::get(ints)) \u003c\u003c std::endl;\n    }\n    if (doubles)\n    {\n        std::cout \u003c\u003c \"doubles found: \" \u003c\u003c std::get\u003c0\u003e(args::get(doubles)) \u003c\u003c \" and \" \u003c\u003c std::get\u003c1\u003e(args::get(doubles)) \u003c\u003c std::endl;\n    }\n    return 0;\n}\n```\n\n```shell\n % ./test -h\nArgument could not be matched: 'h'\n  ./test [INTS] [DOUBLES] \n\n    This is a test program. \n\n  OPTIONS:\n\n      INTS               This takes a pair of integers. \n      DOUBLES            This takes a pair of doubles. \n\n % ./test 5\nints found: 5 and 0\n % ./test 5,8\nints found: 5 and 8\n % ./test 5,8 2.4,8\nints found: 5 and 8\ndoubles found: 2.4 and 8\n % ./test 5,8 2.4, \nterminate called after throwing an instance of 'std::invalid_argument'\n  what():  stod\nzsh: abort      ./test 5,8 2.4,\n % ./test 5,8 2.4 \nterminate called after throwing an instance of 'std::out_of_range'\n  what():  basic_string::basic_string: __pos (which is 4) \u003e this-\u003esize() (which is 3)\nzsh: abort      ./test 5,8 2.4\n % ./test 5,8 2.4-7\nints found: 5 and 8\ndoubles found: 2.4 and 7\n % ./test 5,8 2.4,-7\nints found: 5 and 8\ndoubles found: 2.4 and -7\n```\n\nAs you can see, with your own types, validation can get a little weird.  Make\nsure to check and throw a parsing error (or whatever error you want to catch)\nif you can't fully deduce your type.  The built-in validator will only throw if\nthere are unextracted characters left in the stream.\n\n## Long descriptions and proper wrapping and listing\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cargs.hxx\u003e\nint main(int argc, char **argv)\n{\n    args::ArgumentParser parser(\"This is a test program with a really long description that is probably going to have to be wrapped across multiple different lines.  This is a test to see how the line wrapping works\", \"This goes after the options.  This epilog is also long enough that it will have to be properly wrapped to display correctly on the screen\");\n    args::HelpFlag help(parser, \"HELP\", \"Show this help menu.\", {'h', \"help\"});\n    args::ValueFlag\u003cstd::string\u003e foo(parser, \"FOO\", \"The foo flag.\", {'a', 'b', 'c', \"a\", \"b\", \"c\", \"the-foo-flag\"});\n    args::ValueFlag\u003cstd::string\u003e bar(parser, \"BAR\", \"The bar flag.  This one has a lot of options, and will need wrapping in the description, along with its long flag list.\", {'d', 'e', 'f', \"d\", \"e\", \"f\"});\n    args::ValueFlag\u003cstd::string\u003e baz(parser, \"FOO\", \"The baz flag.  This one has a lot of options, and will need wrapping in the description, even with its short flag list.\", {\"baz\"});\n    args::Positional\u003cstd::string\u003e pos1(parser, \"POS1\", \"The pos1 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist1(parser, \"POSLIST1\", \"The poslist1 argument.\");\n    args::Positional\u003cstd::string\u003e pos2(parser, \"POS2\", \"The pos2 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist2(parser, \"POSLIST2\", \"The poslist2 argument.\");\n    args::Positional\u003cstd::string\u003e pos3(parser, \"POS3\", \"The pos3 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist3(parser, \"POSLIST3\", \"The poslist3 argument.\");\n    args::Positional\u003cstd::string\u003e pos4(parser, \"POS4\", \"The pos4 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist4(parser, \"POSLIST4\", \"The poslist4 argument.\");\n    args::Positional\u003cstd::string\u003e pos5(parser, \"POS5\", \"The pos5 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist5(parser, \"POSLIST5\", \"The poslist5 argument.\");\n    args::Positional\u003cstd::string\u003e pos6(parser, \"POS6\", \"The pos6 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist6(parser, \"POSLIST6\", \"The poslist6 argument.\");\n    args::Positional\u003cstd::string\u003e pos7(parser, \"POS7\", \"The pos7 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist7(parser, \"POSLIST7\", \"The poslist7 argument.\");\n    args::Positional\u003cstd::string\u003e pos8(parser, \"POS8\", \"The pos8 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist8(parser, \"POSLIST8\", \"The poslist8 argument.\");\n    args::Positional\u003cstd::string\u003e pos9(parser, \"POS9\", \"The pos9 argument.\");\n    args::PositionalList\u003cstd::string\u003e poslist9(parser, \"POSLIST9\", \"The poslist9 argument.\");\n    try\n    {\n        parser.ParseCLI(argc, argv);\n    }\n    catch (args::Help)\n    {\n        std::cout \u003c\u003c parser;\n        return 0;\n    }\n    catch (args::ParseError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    catch (args::ValidationError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    return 0;\n}\n```\n\n```shell\n % ./test -h\n  ./test {OPTIONS} [POS1] [POSLIST1...] [POS2] [POSLIST2...] [POS3]\n      [POSLIST3...] [POS4] [POSLIST4...] [POS5] [POSLIST5...] [POS6]\n      [POSLIST6...] [POS7] [POSLIST7...] [POS8] [POSLIST8...] [POS9]\n      [POSLIST9...] \n\n    This is a test program with a really long description that is probably going\n    to have to be wrapped across multiple different lines. This is a test to see\n    how the line wrapping works \n\n  OPTIONS:\n\n      -h, --help         Show this help menu. \n      -a FOO, -b FOO, -c FOO, --a FOO, --b FOO, --c FOO, --the-foo-flag FOO\n                         The foo flag. \n      -d BAR, -e BAR, -f BAR, --d BAR, --e BAR, --f BAR\n                         The bar flag. This one has a lot of options, and will\n                         need wrapping in the description, along with its long\n                         flag list. \n      --baz FOO          The baz flag. This one has a lot of options, and will\n                         need wrapping in the description, even with its short\n                         flag list. \n      POS1               The pos1 argument. \n      POSLIST1           The poslist1 argument. \n      POS2               The pos2 argument. \n      POSLIST2           The poslist2 argument. \n      POS3               The pos3 argument. \n      POSLIST3           The poslist3 argument. \n      POS4               The pos4 argument. \n      POSLIST4           The poslist4 argument. \n      POS5               The pos5 argument. \n      POSLIST5           The poslist5 argument. \n      POS6               The pos6 argument. \n      POSLIST6           The poslist6 argument. \n      POS7               The pos7 argument. \n      POSLIST7           The poslist7 argument. \n      POS8               The pos8 argument. \n      POSLIST8           The poslist8 argument. \n      POS9               The pos9 argument. \n      POSLIST9           The poslist9 argument. \n      \"--\" can be used to terminate flag options and force all following\n      arguments to be treated as positional options \n\n    This goes after the options. This epilog is also long enough that it will\n    have to be properly wrapped to display correctly on the screen \n %\n```\n\n## Completion\n\nCompletion currently only supports bash.\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cargs.hxx\u003e\nint main(int argc, char **argv)\n{\n    args::ArgumentParser parser(\"This is a test program.\", \"This goes after the options.\");\n    args::HelpFlag help(parser, \"help\", \"Display this help menu\", {'h', \"help\"});\n    args::CompletionFlag completion(parser, {\"complete\"});\n    args::ValueFlag\u003cstd::string\u003e foo(parser, \"name\", \"description\", {'f', \"foo\"}, \"abc\");\n    args::ValueFlag\u003cstd::string\u003e bar(parser, \"name\", \"description\", {'b', \"bar\"}, \"abc\");\n    args::ValueFlag\u003cstd::string\u003e baz(parser, \"name\", \"description\", {'a', \"baz\"}, \"abc\");\n    try\n    {\n        parser.ParseCLI(argc, argv);\n    }\n    catch (const args::Completion\u0026 e)\n    {\n        std::cout \u003c\u003c e.what();\n        return 0;\n    }\n    catch (const args::Help\u0026)\n    {\n        std::cout \u003c\u003c parser;\n        return 0;\n    }\n    catch (const args::ParseError\u0026 e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    return 0;\n}\n```\n\n```sh\ng++ -ocompletiontest ./completiontest.cxx \"-I$args_path\"\nPATH=\"$PWD:$PATH\"\n_args() {\n    _init_completion -n 2\u003e /dev/null\n    local program comparg\n\n    program=\"${COMP_WORDS[0]}\"\n    comparg=\"--complete\" # replace this with your flag\n\n    COMPREPLY=($(\"$program\" \"$comparg\" bash \"$COMP_CWORD\" \"${COMP_WORDS[@]}\" 2\u003e /dev/null))\n    [[ $COMPREPLY ]] \u0026\u0026 return\n    _filedir\n}\ncomplete -F _args completiontest\n\n# Now when you type `completiontest --` and press tab, you'll get completion\n```\n\n## Customizing parser prefixes\n\n### dd-style\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cargs.hxx\u003e\nint main(int argc, char **argv)\n{\n    args::ArgumentParser parser(\"This command likes to break your disks\");\n    parser.LongPrefix(\"\");\n    parser.LongSeparator(\"=\");\n    args::HelpFlag help(parser, \"HELP\", \"Show this help menu.\", {\"help\"});\n    args::ValueFlag\u003clong\u003e bs(parser, \"BYTES\", \"Block size\", {\"bs\"}, 512);\n    args::ValueFlag\u003clong\u003e skip(parser, \"BYTES\", \"Bytes to skip\", {\"skip\"}, 0);\n    args::ValueFlag\u003cstd::string\u003e input(parser, \"BLOCK SIZE\", \"Block size\", {\"if\"});\n    args::ValueFlag\u003cstd::string\u003e output(parser, \"BLOCK SIZE\", \"Block size\", {\"of\"});\n    try\n    {\n        parser.ParseCLI(argc, argv);\n    }\n    catch (args::Help)\n    {\n        std::cout \u003c\u003c parser;\n        return 0;\n    }\n    catch (args::ParseError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    catch (args::ValidationError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        std::cerr \u003c\u003c parser;\n        return 1;\n    }\n    std::cout \u003c\u003c \"bs = \" \u003c\u003c args::get(bs) \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"skip = \" \u003c\u003c args::get(skip) \u003c\u003c std::endl;\n    if (input) { std::cout \u003c\u003c \"if = \" \u003c\u003c args::get(input) \u003c\u003c std::endl; }\n    if (output) { std::cout \u003c\u003c \"of = \" \u003c\u003c args::get(output) \u003c\u003c std::endl; }\n    return 0;\n}\n```\n\n```shell\n % ./test help\n  ./test {OPTIONS}\n\n    This command likes to break your disks\n\n  OPTIONS:\n\n      help                              Show this help menu.\n      bs=[BYTES]                        Block size\n      skip=[BYTES]                      Bytes to skip\n      if=[BLOCK SIZE]                   Block size\n      of=[BLOCK SIZE]                   Block size\n\n % ./test bs=1024 skip=7 if=/tmp/input\nbs = 1024\nskip = 7\nif = /tmp/input\n```\n\n### Windows style\n\nThe code is the same as above, but the two lines are replaced out:\n\n```cpp\nparser.LongPrefix(\"/\");\nparser.LongSeparator(\":\");\n```\n\n```shell\n % ./test /help     \n  ./test {OPTIONS}\n\n    This command likes to break your disks\n\n  OPTIONS:\n\n      /help                             Show this help menu.\n      /bs:[BYTES]                       Block size\n      /skip:[BYTES]                     Bytes to skip\n      /if:[BLOCK SIZE]                  Block size\n      /of:[BLOCK SIZE]                  Block size\n\n % ./test /bs:72 /skip:87 /if:/tmp/test.txt\nbs = 72\nskip = 87\nif = /tmp/test.txt\n % \n```\n\n## Group nesting help menu text\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cargs.hxx\u003e\nint main(int argc, char **argv)\n{\n    args::ArgumentParser parser(\"This is a test program.\", \"This goes after the options.\");\n    args::Group xorgroup(parser, \"this group provides xor validation:\", args::Group::Validators::Xor);\n    args::Flag a(xorgroup, \"a\", \"test flag\", {'a'});\n    args::Flag b(xorgroup, \"b\", \"test flag\", {'b'});\n    args::Flag c(xorgroup, \"c\", \"test flag\", {'c'});\n    args::Group nxor(xorgroup, \"this group provides all-or-none (nxor) validation:\", args::Group::Validators::AllOrNone);\n    args::Flag d(nxor, \"d\", \"test flag\", {'d'});\n    args::Flag e(nxor, \"e\", \"test flag\", {'e'});\n    args::Flag f(nxor, \"f\", \"test flag\", {'f'});\n    args::Group nxor2(nxor, \"this group provides all-or-none (nxor2) validation:\", args::Group::Validators::AllOrNone);\n    args::Flag i(nxor2, \"i\", \"test flag\", {'i'});\n    args::Flag j(nxor2, \"j\", \"test flag\", {'j'});\n    args::Flag k(nxor2, \"k\", \"test flag\", {'k'});\n    args::Group nxor3(nxor, \"this group provides all-or-none (nxor3) validation:\", args::Group::Validators::AllOrNone);\n    args::Flag l(nxor3, \"l\", \"test flag\", {'l'});\n    args::Flag m(nxor3, \"m\", \"test flag\", {'m'});\n    args::Flag n(nxor3, \"n\", \"test flag\", {'n'});\n    args::Group atleastone(xorgroup, \"this group provides at-least-one validation:\", args::Group::Validators::AtLeastOne);\n    args::Flag g(atleastone, \"g\", \"test flag\", {'g'});\n    args::Flag o(atleastone, \"o\", \"test flag\", {'o'});\n    args::HelpFlag help(parser, \"help\", \"Show this help menu\", {'h', \"help\"});\n    try\n    {\n        parser.ParseCLI(argc, argv);\n    }\n    catch (args::Help)\n    {\n        std::cout \u003c\u003c parser;\n        return 0;\n    }\n    catch (args::ParseError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        parser.Help(std::cerr);\n        return 1;\n    }\n    catch (args::ValidationError e)\n    {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n        parser.Help(std::cerr);\n        return 1;\n    }\n    return 0;\n}\n```\n\n```shell\n % /tmp/test -h\n  /tmp/test {OPTIONS} \n\n    This is a test program. \n\n  OPTIONS:\n\n                         this group provides xor validation: \n        -a                 test flag \n        -b                 test flag \n        -c                 test flag \n                           this group provides all-or-none (nxor) validation: \n          -d                 test flag \n          -e                 test flag \n          -f                 test flag \n                             this group provides all-or-none (nxor2) validation:\n            -i                 test flag \n            -j                 test flag \n            -k                 test flag \n                             this group provides all-or-none (nxor3) validation:\n            -l                 test flag \n            -m                 test flag \n            -n                 test flag \n                           this group provides at-least-one validation: \n          -g                 test flag \n          -o                 test flag \n      -h, --help         Show this help menu \n\n    This goes after the options. \n %                                                                                \n```\n\n## Mapping arguments\n\nI haven't written out a long example for this, but here's the test case you should be able to discern the meaning from:\n\n```cpp\nbool ToLowerReader(const std::string \u0026name, const std::string \u0026value, std::string \u0026destination)\n{\n    destination = value;\n    std::transform(destination.begin(), destination.end(), destination.begin(), ::tolower);\n    return true;\n}\n\nTEST_CASE(\"Mapping types work as needed\", \"[args]\")\n{\n    std::unordered_map\u003cstd::string, MappingEnum\u003e map{\n        {\"default\", MappingEnum::def},\n        {\"foo\", MappingEnum::foo},\n        {\"bar\", MappingEnum::bar},\n        {\"red\", MappingEnum::red},\n        {\"yellow\", MappingEnum::yellow},\n        {\"green\", MappingEnum::green}};\n    args::ArgumentParser parser(\"This is a test program.\", \"This goes after the options.\");\n    args::MapFlag\u003cstd::string, MappingEnum\u003e dmf(parser, \"DMF\", \"Maps string to an enum\", {\"dmf\"}, map);\n    args::MapFlag\u003cstd::string, MappingEnum\u003e mf(parser, \"MF\", \"Maps string to an enum\", {\"mf\"}, map);\n    args::MapFlag\u003cstd::string, MappingEnum, ToLowerReader\u003e cimf(parser, \"CIMF\", \"Maps string to an enum case-insensitively\", {\"cimf\"}, map);\n    args::MapFlagList\u003cstd::string, MappingEnum\u003e mfl(parser, \"MFL\", \"Maps string to an enum list\", {\"mfl\"}, map);\n    args::MapPositional\u003cstd::string, MappingEnum\u003e mp(parser, \"MP\", \"Maps string to an enum\", map);\n    args::MapPositionalList\u003cstd::string, MappingEnum\u003e mpl(parser, \"MPL\", \"Maps string to an enum list\", map);\n    parser.ParseArgs(std::vector\u003cstd::string\u003e{\"--mf=red\", \"--cimf=YeLLoW\", \"--mfl=bar\", \"foo\", \"--mfl=green\", \"red\", \"--mfl\", \"bar\", \"default\"});\n    REQUIRE_FALSE(dmf);\n    REQUIRE(args::get(dmf) == MappingEnum::def);\n    REQUIRE(mf);\n    REQUIRE(args::get(mf) == MappingEnum::red);\n    REQUIRE(cimf);\n    REQUIRE(args::get(cimf) == MappingEnum::yellow);\n    REQUIRE(mfl);\n    REQUIRE((args::get(mfl) == std::vector\u003cMappingEnum\u003e{MappingEnum::bar, MappingEnum::green, MappingEnum::bar}));\n    REQUIRE(mp);\n    REQUIRE((args::get(mp) == MappingEnum::foo));\n    REQUIRE(mpl);\n    REQUIRE((args::get(mpl) == std::vector\u003cMappingEnum\u003e{MappingEnum::red, MappingEnum::def}));\n    REQUIRE_THROWS_AS(parser.ParseArgs(std::vector\u003cstd::string\u003e{\"--mf=YeLLoW\"}), args::MapError);\n}\n```\n\n# How fast is it?\n\nThis should not really be a question you ask when you are looking for an\nargument-parsing library, but every test I've done shows args as being about\n65% faster than TCLAP and 220% faster than boost::program_options.\n\nThe simplest benchmark I threw together is the following one, which parses the\ncommand line `-i 7 -c a 2.7 --char b 8.4 -c c 8.8 --char d` with a parser that\nparses -i as an int, -c as a list of chars, and the positional parameters as a\nlist of doubles (the command line was originally much more complex, but TCLAP's\nlimitations made me trim it down so I could use a common command line across\nall libraries.  I also have to copy in the arguments list with every run,\nbecause TCLAP permutes its argument list as it runs (and comparison would have\nbeen unfair without comparing all about equally), but that surprisingly didn't\naffect much.  Also tested is pulling the arguments out, but that was fast\ncompared to parsing, as would be expected.\n\n### The run:\n\n```shell\n% g++ -obench bench.cxx -O2 -std=c++11 -lboost_program_options\n% ./bench\nargs seconds to run: 0.895472\ntclap seconds to run: 1.45001\nboost::program_options seconds to run: 1.98972\n%\n```\n\n### The benchmark:\n\n```cpp\n#undef NDEBUG\n#include \u003ciostream\u003e\n#include \u003cchrono\u003e\n#include \u003ccassert\u003e\n#include \"args.hxx\"\n#include \u003ctclap/CmdLine.h\u003e\n#include \u003cboost/program_options.hpp\u003e\nnamespace po = boost::program_options;\nusing namespace std::chrono;\ninline bool doubleequals(const double a, const double b)\n{\n    static const double delta = 0.0001;\n    const double diff = a - b;\n    return diff \u003c delta \u0026\u0026 diff \u003e -delta;\n}\nint main()\n{\n    const std::vector\u003cstd::string\u003e carguments({\"-i\", \"7\", \"-c\", \"a\", \"2.7\", \"--char\", \"b\", \"8.4\", \"-c\", \"c\", \"8.8\", \"--char\", \"d\"});\n    const std::vector\u003cstd::string\u003e pcarguments({\"progname\", \"-i\", \"7\", \"-c\", \"a\", \"2.7\", \"--char\", \"b\", \"8.4\", \"-c\", \"c\", \"8.8\", \"--char\", \"d\"});\n    // args\n    {\n        high_resolution_clock::time_point start = high_resolution_clock::now();\n        for (unsigned int x = 0; x \u003c 100000; ++x)\n        {\n            std::vector\u003cstd::string\u003e arguments(carguments);\n            args::ArgumentParser parser(\"This is a test program.\", \"This goes after the options.\");\n            args::ValueFlag\u003cint\u003e integer(parser, \"integer\", \"The integer flag\", {'i', \"int\"});\n            args::ValueFlagList\u003cchar\u003e characters(parser, \"characters\", \"The character flag\", {'c', \"char\"});\n            args::PositionalList\u003cdouble\u003e numbers(parser, \"numbers\", \"The numbers position list\");\n            parser.ParseArgs(arguments);\n            const int i = args::get(integer);\n            const std::vector\u003cchar\u003e c(args::get(characters));\n            const std::vector\u003cdouble\u003e n(args::get(numbers));\n            assert(i == 7);\n            assert(c[0] == 'a');\n            assert(c[1] == 'b');\n            assert(c[2] == 'c');\n            assert(c[3] == 'd');\n            assert(doubleequals(n[0], 2.7));\n            assert(doubleequals(n[1], 8.4));\n            assert(doubleequals(n[2], 8.8));\n        }\n        high_resolution_clock::duration runtime = high_resolution_clock::now() - start;\n        std::cout \u003c\u003c \"args seconds to run: \" \u003c\u003c duration_cast\u003cduration\u003cdouble\u003e\u003e(runtime).count() \u003c\u003c std::endl;\n    }\n    // tclap\n    {\n        high_resolution_clock::time_point start = high_resolution_clock::now();\n        for (unsigned int x = 0; x \u003c 100000; ++x)\n        {\n            std::vector\u003cstd::string\u003e arguments(pcarguments);\n            TCLAP::CmdLine cmd(\"Command description message\", ' ', \"0.9\");\n            TCLAP::ValueArg\u003cint\u003e integer(\"i\", \"int\", \"The integer flag\", false, 0, \"integer\", cmd);\n            TCLAP::MultiArg\u003cchar\u003e characters(\"c\", \"char\", \"The character flag\", false, \"characters\", cmd);\n            TCLAP::UnlabeledMultiArg\u003cdouble\u003e numbers(\"numbers\", \"The numbers position list\", false, \"foo\", cmd, false);\n            cmd.parse(arguments);\n            const int i = integer.getValue();\n            const std::vector\u003cchar\u003e c(characters.getValue());\n            const std::vector\u003cdouble\u003e n(numbers.getValue());\n            assert(i == 7);\n            assert(c[0] == 'a');\n            assert(c[1] == 'b');\n            assert(c[2] == 'c');\n            assert(c[3] == 'd');\n            assert(doubleequals(n[0], 2.7));\n            assert(doubleequals(n[1], 8.4));\n            assert(doubleequals(n[2], 8.8));\n        }\n        high_resolution_clock::duration runtime = high_resolution_clock::now() - start;\n        std::cout \u003c\u003c \"tclap seconds to run: \" \u003c\u003c duration_cast\u003cduration\u003cdouble\u003e\u003e(runtime).count() \u003c\u003c std::endl;\n    }\n    // boost::program_options\n    {\n        high_resolution_clock::time_point start = high_resolution_clock::now();\n        for (unsigned int x = 0; x \u003c 100000; ++x)\n        {\n            std::vector\u003cstd::string\u003e arguments(carguments);\n            po::options_description desc(\"This is a test program.\");\n            desc.add_options()\n                (\"int,i\", po::value\u003cint\u003e(), \"The integer flag\")\n                (\"char,c\", po::value\u003cstd::vector\u003cchar\u003e\u003e(), \"The character flag\")\n                (\"numbers\", po::value\u003cstd::vector\u003cdouble\u003e\u003e(), \"The numbers flag\");\n            po::positional_options_description p;\n            p.add(\"numbers\", -1);\n            po::variables_map vm;\n            po::store(po::command_line_parser(carguments).options(desc).positional(p).run(), vm);\n            const int i = vm[\"int\"].as\u003cint\u003e();\n            const std::vector\u003cchar\u003e c(vm[\"char\"].as\u003cstd::vector\u003cchar\u003e\u003e());\n            const std::vector\u003cdouble\u003e n(vm[\"numbers\"].as\u003cstd::vector\u003cdouble\u003e\u003e());\n            assert(i == 7);\n            assert(c[0] == 'a');\n            assert(c[1] == 'b');\n            assert(c[2] == 'c');\n            assert(c[3] == 'd');\n            assert(doubleequals(n[0], 2.7));\n            assert(doubleequals(n[1], 8.4));\n            assert(doubleequals(n[2], 8.8));\n        }\n        high_resolution_clock::duration runtime = high_resolution_clock::now() - start;\n        std::cout \u003c\u003c \"boost::program_options seconds to run: \" \u003c\u003c duration_cast\u003cduration\u003cdouble\u003e\u003e(runtime).count() \u003c\u003c std::endl;\n    }\n    return 0;\n}\n```\n\nSo, on top of being more flexible, smaller, and easier to read, it is faster\nthan the most common alternatives.\n","funding_links":[],"categories":["CLI","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaywee%2Fargs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaywee%2Fargs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaywee%2Fargs/lists"}