{"id":26099276,"url":"https://github.com/djoezeke/myargs","last_synced_at":"2025-03-09T16:35:41.538Z","repository":{"id":281279645,"uuid":"944220351","full_name":"djoezeke/myargs","owner":"djoezeke","description":"A Straight forward Command-line arguments parsing library for modern C/C++  that would make your day.","archived":false,"fork":false,"pushed_at":"2025-03-08T01:58:14.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T02:24:49.185Z","etag":null,"topics":["argument-parser","c","cli","command-line","console","cplusplus","flag","options","parsing","subcommands"],"latest_commit_sha":null,"homepage":"","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/djoezeke.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"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":"2025-03-07T01:30:43.000Z","updated_at":"2025-03-08T01:58:18.000Z","dependencies_parsed_at":"2025-03-08T02:34:53.290Z","dependency_job_id":null,"html_url":"https://github.com/djoezeke/myargs","commit_stats":null,"previous_names":["djoezeke/myargs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djoezeke%2Fmyargs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djoezeke%2Fmyargs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djoezeke%2Fmyargs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djoezeke%2Fmyargs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djoezeke","download_url":"https://codeload.github.com/djoezeke/myargs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242721296,"owners_count":20174799,"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","c","cli","command-line","console","cplusplus","flag","options","parsing","subcommands"],"created_at":"2025-03-09T16:35:40.927Z","updated_at":"2025-03-09T16:35:41.516Z","avatar_url":"https://github.com/djoezeke.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MyArgs | Modern Argument Parser\n\n## 📖 Description\n\nA lightweight header-only library for parsing command-line arguments, including support for flags and keyword arguments in an elegant manner.\n\n## ✨ Features\n\n- Parse keyword arguments\n- Parse positional arguments\n- Parse flags\n- Set default values for arguments\n- Print help messages\n\nMyArgs distinguishes 3 different types of arguments:\n\n| Type    | Functin   | Description                                                             |\n| ------- | --------- | ----------------------------------------------------------------------- |\n| `arg`   | add_arg   | named positional arguments (e.g. file)                                  |\n| `flag`  | add_flag  | a boolean argument that is by default false (e.g. --verbose)            |\n| `kwarg` | add_kwarg | keyworded-arguments that require a key and a value, (e.g. --variable=5) |\n\n### 📝 Supported Syntax\n\n```\n--help --verbose --input=file.txt\n-hvi=file.txt\n-h --verbose -i file.txt\n--long value\n```\n\n## 🛠️ Installation\n\nTo use MyArgs in your project, simply include the `myargs.h` header file in your source files.\n\n```cpp\n#include \"myargs.h\"\n```\n\n## 🚀 Usage\n\n```c\n#include \"myargs.h\"\n\nint main(int argc, char *argv[])\n{\n    ArgumentParser parser;\n\n    init_parser(\u0026parser, NULL, NULL, NULL, NULL, 1);\n\n    add_flag(\u0026parser, 'v', \"verbose\", \"Enable verbose mode\");\n    add_flag(\u0026parser, 's', \"store\", \"Save file Name\");\n    add_kwarg(\u0026parser, 'c', \"count\", 0, NULL, \"Number of times\");\n\n    parse_args(\u0026parser, argc, argv);\n\n    int verbose = get_flag(\u0026parser, \"verbose\");\n    int store = get_flag(\u0026parser, \"store\");\n    int help = get_flag(\u0026parser, \"help\");\n    const char *count = get_kwarg(\u0026parser, \"count\");\n\n    if (help)\n        print_help(\u0026parser, 1, 1, 1, 1);\n    if (count)\n        printf(\"Count: %s\\n\", count);\n    if (store)\n        printf(\"Store: %d\\n\", store);\n    if (verbose)\n        printf(\"Verbose: %d\\n\", verbose);\n\n    free_parser(\u0026parser);\n\n    return 0;\n}\n```\n\n### Example Help\n\n```sh\n$ ./sample --help\nWelcome to MyArgs\nUsage: ./sample file.txt -v [FILE] [-h | -v ] [--output FILE]  [options...]\n            file.txt : Output path [required]\n            -v : Verbose Output [default: false]\n\nOptions:\n               -k : An implicit int parameter [implicit: \"3\", required]\n       -a,--alpha : An optional float parameter with default value [default: 0.6]\n        -b,--beta : An optional float parameter with std::optional return [default: none]\n     -n,--numbers : An int vector, comma separated [required]\n          --files : multiple arguments [required]\n       -c,--color : An Enum input [allowed: \u003cred, blue, green\u003e, required]\n     -v,--verbose : A flag to toggle verbose [implicit: \"true\", default: false]\n           --help : print help [implicit: \"true\", default: false]\n```\n\n## License 📄\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contributing 🤝\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n\n## Acknowledgements 🙏\n\nMyArgs is inspired by Python Argparse and aims to provide a simple and lightweight solution for C/C++ projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjoezeke%2Fmyargs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjoezeke%2Fmyargs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjoezeke%2Fmyargs/lists"}