{"id":20726313,"url":"https://github.com/konstantintutsch/zarg","last_synced_at":"2026-05-27T21:31:48.939Z","repository":{"id":228079053,"uuid":"771720933","full_name":"konstantintutsch/zarg","owner":"konstantintutsch","description":"A minimalist C library for simple handling of command line arguments. 🚀","archived":false,"fork":false,"pushed_at":"2024-09-24T13:59:01.000Z","size":435,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-11T08:51:13.214Z","etag":null,"topics":["c","cmd","library","parser"],"latest_commit_sha":null,"homepage":"https://konstantintutsch.com/zarg","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/konstantintutsch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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":"2024-03-13T20:29:28.000Z","updated_at":"2024-09-24T14:02:55.000Z","dependencies_parsed_at":"2024-11-17T07:18:04.165Z","dependency_job_id":null,"html_url":"https://github.com/konstantintutsch/zarg","commit_stats":null,"previous_names":["konstantintutsch/zarg"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/konstantintutsch/zarg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantintutsch%2Fzarg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantintutsch%2Fzarg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantintutsch%2Fzarg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantintutsch%2Fzarg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konstantintutsch","download_url":"https://codeload.github.com/konstantintutsch/zarg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantintutsch%2Fzarg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33585203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["c","cmd","library","parser"],"created_at":"2024-11-17T04:24:22.499Z","updated_at":"2026-05-27T21:31:48.923Z","avatar_url":"https://github.com/konstantintutsch.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zarg\n\nA minimalist C library for simple handling of command line arguments. 🚀\n\n## Example\n\nHow to implement _zarg_ in a program.\n\n```c\n#include \u003cstdio.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003czarg.h\u003e\n\nint main(int argc, char *argv[])\n{\n    Flag plus = { \"add\", 'a', true, \"Add up numbers\" };\n    Flag encourage = { \"encourage\", 'e', false, \"Encourage the user\" };\n    Flag flags[] = { plus, encourage, _FLAG };\n\n    // Help dialogue\n    if (zinit(argv, flags))\n        return 0;\n\n    int total = 0;\n\n    char **numbers = flag_value(argv, plus);\n    for (int i = 0; i \u003c ppclen(numbers); i++)   // Do not use flag_count() here, this will inevitably lead to a memory leak.\n        total += atoi(numbers[i]);\n    free(numbers);              // Always call free() on the return of flag_value()\n    printf(\"Your numbers sum up to %d!\\n\", total);\n\n    if (flag_passed(argv, encourage))\n        printf\n            (\"Great job! That's how one should pass command line arguments!\\n\");\n\n    char **files = argument_value(argv, flags); // Get all arguments not in relation to any Flag\n    if (ppclen(files) \u003e 0) {\n        printf(\"You also passed these files …\\n\");    // There were such arguments\n        for (int i = 0; i \u003c ppclen(files); i++)\n            printf(\"- %s\\n\", files[i]);\n        printf(\"... which will be completely ignored!\\n\");\n    }\n    free(files);                // Always call free() on the return of argument_value()\n\n    return 0;\n}\n```\n\nCompile.\n\n```\n$ gcc -Wall -fstack-protector -lzarg myzarg.c -o myzarg\n```\n\nThen execute:\n\n```\n$ ./myzarg --help\n./myzarg [option]\n\nOptions\n--help, -h        Show this dialogue\n--add, -a [value] Add up numbers\n--encourage, -e   Encourage the user\n```\n\n… or\n\n```\n$ ./myzarg --add 2 -a 40\nYour numbers sum up to 42!\n```\n\nIf you've had a bad day, add `--encourage`!\n\n```\n$ ./myzarg --encourage -a 40 -a 2\nYour numbers sum up to 42!\nGreat job! That's how one should pass command line arguments!\n```\n\nWait, can I pass input files?\n\n```\n$ ./myzarg -a 21 file.txt -a 21 another_file.txt -e a_third_file.txt an_image.jpg\nYour numbers sum up to 42!\nGreat job! That's how one should pass command line arguments!\nYou also passed these files …\n- file.txt\n- another_file.txt\n- a_third_file.txt\n- an_image.jpg\n... which will be completely ignored!\n```\n\nSure thing!\n\n## Installation\n\n### Prerequisites\n\n-   make (_v4.4+_)\n-   gcc (_v14.1+_)\n\n### Compiling\n\nTo compile libzarg using make.\n\n```\n$ make build/libzarg.so\n```\n\nAfter building libzarg, execute the `install` rule with root privileges to install libzarg to your system.\n\n```\n# make install\n```\n\n## Removal\n\nExecute the `uninstall` rule with root privileges to completely remove libzarg from your system.\n\n```\n# make uninstall\n```\n\n## Testing\n\nFollow the installation instructions. Once finished, build the base testing binary using make.\n\n```\n$ make build/test\n```\n\nNow run the automated testing script\n\n```\n$ make test\n```\n\n… or test manually.\n\n```\n$ ./build/test --help\n```\n\n## Documentation\n\nTo better understand functions and code provided by this library, open [this site](https://konstantintutsch.com/zarg/globals.html) with your browser of choice.\n\n\nIf you want to view the documentation offline, use [Doxygen](https://doxygen.nl). Just run the `doc` rule with make.\n\n```\n$ make doc\n```\n\nYou can now view all documentation locally. A good entry point is `./build/doc/html/globals.html`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonstantintutsch%2Fzarg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonstantintutsch%2Fzarg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonstantintutsch%2Fzarg/lists"}