{"id":18858323,"url":"https://github.com/dmgk/zig-getopt","last_synced_at":"2025-10-10T22:45:50.770Z","repository":{"id":49685712,"uuid":"369233054","full_name":"dmgk/zig-getopt","owner":"dmgk","description":"POSIX-compatible getopt(3) implementation in Zig","archived":false,"fork":false,"pushed_at":"2024-07-16T00:34:32.000Z","size":10,"stargazers_count":19,"open_issues_count":3,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T01:59:08.887Z","etag":null,"topics":["option-parser","option-parsing","zig","zig-package","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmgk.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,"zenodo":null}},"created_at":"2021-05-20T14:17:44.000Z","updated_at":"2025-07-11T10:03:33.000Z","dependencies_parsed_at":"2025-04-14T11:56:03.040Z","dependency_job_id":"cbaea691-22d9-4e08-8ba8-670fa80b8d06","html_url":"https://github.com/dmgk/zig-getopt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dmgk/zig-getopt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fzig-getopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fzig-getopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fzig-getopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fzig-getopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmgk","download_url":"https://codeload.github.com/dmgk/zig-getopt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fzig-getopt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005463,"owners_count":26083902,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"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":["option-parser","option-parsing","zig","zig-package","ziglang"],"created_at":"2024-11-08T04:11:56.910Z","updated_at":"2025-10-10T22:45:50.730Z","avatar_url":"https://github.com/dmgk.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimal POSIX getopt(3) implementation in Zig\n\nThis is a minimal, allocation-free getopt(3) implementation with [POSIX-conforming](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html) argument parsing semantics.\n\n## Example\n\n```zig\nconst std = @import(\"std\");\nconst debug = std.debug;\nconst getopt = @import(\"getopt.zig\");\n\npub fn main() void {\n    var arg: []const u8 = undefined;\n    var verbose: bool = false;\n\n    var opts = getopt.getopt(\"a:vh\");\n\n    while (opts.next()) |maybe_opt| {\n        if (maybe_opt) |opt| {\n            switch (opt.opt) {\n                'a' =\u003e {\n                    arg = opt.arg.?;\n                    debug.print(\"arg = {s}\\n\", .{arg});\n                },\n                'v' =\u003e {\n                    verbose = true;\n                    debug.print(\"verbose = {}\\n\", .{verbose});\n                },\n                'h' =\u003e debug.print(\n                    \\\\usage: example [-a arg] [-hv]\n                    \\\\\n                , .{}),\n                else =\u003e unreachable,\n            }\n        } else break;\n    } else |err| {\n        switch (err) {\n            getopt.Error.InvalidOption =\u003e debug.print(\"invalid option: {c}\\n\", .{opts.optopt}),\n            getopt.Error.MissingArgument =\u003e debug.print(\"option requires an argument: {c}\\n\", .{opts.optopt}),\n        }\n    }\n\n    debug.print(\"remaining args: {?s}\\n\", .{opts.args()});\n}\n```\n\n```\n$ zig run example.zig -- -hv -a42 foo bar\nusage: example [-a arg] [-hv]\nverbose = true\narg = 42\nremaining args: { foo, bar }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmgk%2Fzig-getopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmgk%2Fzig-getopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmgk%2Fzig-getopt/lists"}