{"id":13730962,"url":"https://github.com/pfultz2/args","last_synced_at":"2025-04-10T01:08:27.941Z","repository":{"id":48122179,"uuid":"64585260","full_name":"pfultz2/args","owner":"pfultz2","description":"Simple and type-safe commandline argument parser for C++14","archived":false,"fork":false,"pushed_at":"2021-08-05T16:12:24.000Z","size":46,"stargazers_count":66,"open_issues_count":3,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-10T01:08:22.945Z","etag":null,"topics":["argument-parser","command-line-parser","cplusplus","cplusplus-11","cplusplus-14","cpp","cpp11","cpp14"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfultz2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-31T08:51:37.000Z","updated_at":"2024-09-28T14:51:58.000Z","dependencies_parsed_at":"2022-07-25T22:47:58.687Z","dependency_job_id":null,"html_url":"https://github.com/pfultz2/args","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2Fargs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2Fargs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2Fargs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfultz2%2Fargs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfultz2","download_url":"https://codeload.github.com/pfultz2/args/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137887,"owners_count":21053775,"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":["argument-parser","command-line-parser","cplusplus","cplusplus-11","cplusplus-14","cpp","cpp11","cpp14"],"created_at":"2024-08-03T02:01:22.092Z","updated_at":"2025-04-10T01:08:27.919Z","avatar_url":"https://github.com/pfultz2.png","language":"C++","readme":"Args\n====\n\nSimple and typesafe commandline parsing for C++14. \n\nQuickstart\n----------\n\nSimply provide a class with fields that is to be filled by command-line arguments:\n\n```cpp\nstruct hello\n{\n    static const char* help()\n    {\n        return \"Simple program that greets NAME for a total of COUNT times.\";\n    }\n    int count;\n    std::string name;\n\n    hello() : count(1)\n    {}\n\n    template\u003cclass F\u003e\n    void parse(F f)\n    {\n        f(count, \"--count\", \"-C\", args::help(\"Number of greetings.\"));\n        f(name, \"--name\", \"-N\", args::help(\"The person to greet.\"), args::required());\n    }\n\n    void run()\n    {\n        for(int i=0;i\u003ccount;i++) printf(\"%s\\n\", name.c_str());\n    }\n};\n\nint main(int argc, char const *argv[]) \n{\n    args::parse\u003chello\u003e(argc, argv);\n}\n```\n\nThe command then could be run like this:\n\n```\n$ hello --name Paul --count 3\nPaul\nPaul\nPaul\n\n```\n\nThe args library will auto-generate help info:\n\n```\n$ hello --help\nUsage: hello [options...]\n\n  Simple program that greets NAME for a total of COUNT times.  \n\nOptions: \n\n            -h, --help Show help  \n --count, -C [integer] Number of greetings.  \n   --name, -N [string] The person to greet.\n```\n\nIn addition, nested commands can be created:\n\n```cpp\nstruct cli : args::group\u003ccli\u003e\n{\n    static const char* help()\n    {\n        return \"Command-line interface to manage a database\";\n    }\n};\n\nstruct initdb : cli::command\u003cinitdb\u003e\n{\n    initdb() {}\n    static const char* help()\n    {\n        return \"Initialize database\";\n    }\n    void run()\n    {\n        printf(\"Initialize database\\n\");\n    }\n};\n\nstruct dropdb : cli::command\u003cdropdb\u003e\n{\n    dropdb() {}\n    static const char* help()\n    {\n        return \"Delete database\";\n    }\n    void run()\n    {\n        printf(\"Delete database\\n\");\n    }\n};\n\nint main(int argc, char const *argv[]) \n{\n    args::parse\u003ccli\u003e(argc, argv);\n}\n\n```\n\nSo each subcommand can be ran like this:\n\n```\n$ cli initdb\nInitialize database\n```\n\n```\n$ cli dropdb\nDelete database\n```\n\nIn addition help is generated for subcommands as well:\n\n```\n$ cli --help\nUsage: cli [options...] [command]\n\n  Command-line interface to manage a database  \n\nOptions: \n\n -h, --help Show help  \n\nCommands: \n\n     dropdb Delete database  \n     initdb Initialize database  \n\n```\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfultz2%2Fargs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfultz2%2Fargs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfultz2%2Fargs/lists"}