{"id":13830585,"url":"https://github.com/clibs/commander","last_synced_at":"2025-04-09T21:20:13.493Z","repository":{"id":3604951,"uuid":"4669618","full_name":"clibs/commander","owner":"clibs","description":"Commander option parser ported to C - simple API, auto-generated --help","archived":false,"fork":false,"pushed_at":"2025-03-25T19:27:55.000Z","size":42,"stargazers_count":203,"open_issues_count":11,"forks_count":29,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-02T19:06:16.958Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clibs.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"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":"2012-06-14T23:24:15.000Z","updated_at":"2025-03-30T00:40:20.000Z","dependencies_parsed_at":"2024-05-28T03:25:59.677Z","dependency_job_id":null,"html_url":"https://github.com/clibs/commander","commit_stats":{"total_commits":61,"total_committers":6,"mean_commits":"10.166666666666666","dds":0.1311475409836066,"last_synced_commit":"57c397c004c8aaf062a205b7dfcb7a6b6200abd8"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clibs%2Fcommander","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clibs%2Fcommander/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clibs%2Fcommander/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clibs%2Fcommander/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clibs","download_url":"https://codeload.github.com/clibs/commander/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248112224,"owners_count":21049618,"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-08-04T10:01:02.567Z","updated_at":"2025-04-09T21:20:13.464Z","avatar_url":"https://github.com/clibs.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# commander\n\n  Commander option parser ported to C.\n\n## Installation\n\n  Install with [clib](https://github.com/clibs/clib):\n\n```\n$ clib install clibs/commander\n```\n\n## Automated --help\n\n  The [example](#example) below would produce the following `--help`:\n\n```\n\nUsage: example [options]\n\nOptions:\n\n  -V, --version                 output program version\n  -h, --help                    output help information\n  -v, --verbose                 enable verbose stuff\n  -r, --required \u003carg\u003e          required arg\n  -o, --optional [arg]          optional arg\n\n```\n\n## Example\n\n```c\n#include \u003cstdio.h\u003e\n#include \"commander.h\"\n\nstatic void\nverbose(command_t *self) {\n  printf(\"verbose: enabled\\n\");\n}\n\nstatic void\nrequired(command_t *self) {\n  printf(\"required: %s\\n\", self-\u003earg);\n}\n\nstatic void\noptional(command_t *self) {\n  printf(\"optional: %s\\n\", self-\u003earg);\n}\n\nint\nmain(int argc, const char **argv){\n  command_t cmd;\n  command_init(\u0026cmd, argv[0], \"0.0.1\");\n  command_option(\u0026cmd, \"-v\", \"--verbose\", \"enable verbose stuff\", verbose);\n  command_option(\u0026cmd, \"-r\", \"--required \u003carg\u003e\", \"required arg\", required);\n  command_option(\u0026cmd, \"-o\", \"--optional [arg]\", \"optional arg\", optional);\n  command_parse(\u0026cmd, argc, argv);\n  printf(\"additional args:\\n\");\n  for (int i = 0; i \u003c cmd.argc; ++i) {\n    printf(\"  - '%s'\\n\", cmd.argv[i]);\n  }\n  command_free(\u0026cmd);\n  return 0;\n}\n```\n\n## Closure\n\n  `cmd.data` is a `void *` so pass along a struct to the callbacks if you want.\n\n## Usage\n\n  `cmd.usage` defaults to \"[options]\".\n\n## Links\n\n  - Used by the [mon(1)](https://github.com/visionmedia/mon/blob/master/src/mon.c) process monitor\n\n## Short flags\n\n  Compound short flags are automatically expanded to their canonical form. For example `-vLO` would\n  become `-v -L -O`.\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 TJ Holowaychuk \u0026lt;tj@vision-media.ca\u0026gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclibs%2Fcommander","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclibs%2Fcommander","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclibs%2Fcommander/lists"}