{"id":13710480,"url":"https://github.com/ikskuh/zig-args","last_synced_at":"2025-05-16T10:08:46.643Z","repository":{"id":36994113,"uuid":"245008561","full_name":"ikskuh/zig-args","owner":"ikskuh","description":"Simple-to-use argument parser with struct-based config","archived":false,"fork":false,"pushed_at":"2025-03-02T19:33:24.000Z","size":78,"stargazers_count":271,"open_issues_count":8,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-09T07:01:34.847Z","etag":null,"topics":["option-parser","option-parsing","zig","zig-package","ziglang"],"latest_commit_sha":null,"homepage":null,"language":"Zig","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/ikskuh.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},"funding":{"github":"MasterQ32"}},"created_at":"2020-03-04T21:34:00.000Z","updated_at":"2025-03-27T01:21:06.000Z","dependencies_parsed_at":"2023-11-21T10:35:20.743Z","dependency_job_id":"f2f71d8e-b0f0-4000-8f16-8f7ba84dd069","html_url":"https://github.com/ikskuh/zig-args","commit_stats":{"total_commits":95,"total_committers":24,"mean_commits":"3.9583333333333335","dds":0.7578947368421053,"last_synced_commit":"0abdd6947a70e6d8cc83b66228cea614aa856206"},"previous_names":["ikskuh/zig-args","masterq32/zig-args"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikskuh%2Fzig-args","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikskuh%2Fzig-args/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikskuh%2Fzig-args/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikskuh%2Fzig-args/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikskuh","download_url":"https://codeload.github.com/ikskuh/zig-args/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509478,"owners_count":22082892,"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":["option-parser","option-parsing","zig","zig-package","ziglang"],"created_at":"2024-08-02T23:00:57.115Z","updated_at":"2025-05-16T10:08:41.635Z","avatar_url":"https://github.com/ikskuh.png","language":"Zig","readme":"# Zig Argument Parser\nSimple-to-use argument parser with struct-based config\n\n## Features\n- Automatic option generation from a config struct\n- Familiar *look \u0026 feel*:\n    - Everything after the first `--` is assumed to be a positional argument\n    - A single `-` is interpreted as a positional argument which can be used as the stdin/stdout file placeholder\n    - Short options with no argument can be combined into a single argument: `-dfe`\n    - Long options can use either `--option=value` or `--option value` syntax (use `--option=--` if you need `--` as a long option argument)\n    - verbs (sub-commands), with verb specific options. Non-verb specific (global) options can come before or after the\n      verb on the command line. Non-verb option arguments are processed *before* determining verb.  (see `demo_verb.zig`)\n- Integrated support for primitive types:\n    - All integer types (signed \u0026 unsigned)\n    - Floating point types\n    - Booleans (takes optional argument. If no argument given, the bool is set, otherwise, one of `yes`, `true`, `y`, `no`, `false`, `n` is interpreted)\n    - Strings\n    - Enumerations\n\n## Use in your project\n\nAdd the dependency in your `build.zig.zon` by running the following command:\n```bash\nzig fetch --save=args git+https://github.com/ikskuh/zig-args#master\n```\n\nAdd it to your exe in `build.zig`:\n```zig\nexe.root_module.addImport(\"args\", b.dependency(\"args\", .{ .target = target, .optimize = optimize }).module(\"args\"));\n```\n\nThen you can import it from your code:\n```zig\nconst argsParser = @import(\"args\");\n```\n\n## Example\n\n```zig\nconst options = argsParser.parseForCurrentProcess(struct {\n    // This declares long options for double hyphen\n    output: ?[]const u8 = null,\n    @\"with-offset\": bool = false,\n    @\"with-hexdump\": bool = false,\n    @\"intermix-source\": bool = false,\n    numberOfBytes: ?i32 = null,\n    signed_number: ?i64 = null,\n    unsigned_number: ?u64 = null,\n    mode: enum { default, special, slow, fast } = .default,\n\n    // This declares short-hand options for single hyphen\n    pub const shorthands = .{\n        .S = \"intermix-source\",\n        .b = \"with-hexdump\",\n        .O = \"with-offset\",\n        .o = \"output\",\n    };\n}, argsAllocator, .print) catch return 1;\ndefer options.deinit();\n\nstd.debug.print(\"executable name: {?s}\\n\", .{options.executable_name});\n\nstd.debug.print(\"parsed options:\\n\", .{});\ninline for (std.meta.fields(@TypeOf(options.options))) |fld| {\n    std.debug.print(\"\\t{s} = {any}\\n\", .{\n        fld.name,\n        @field(options.options, fld.name),\n    });\n}\n\nstd.debug.print(\"parsed positionals:\\n\", .{});\nfor (options.positionals) |arg| {\n    std.debug.print(\"\\t'{s}'\\n\", .{arg});\n}\n```\n\n## Versions\n\n- Branch [master](https://github.com/ikskuh/zig-args/tree/master) tracks Zig master\n- Branch [0.13.x](https://github.com/ikskuh/zig-args/tree/zig-0.13.x) tracks Zig 0.13.0\n- Tag [0.9.0](https://github.com/ikskuh/zig-args/tree/zig-0.9.0) tracks Zig 0.9.0\n","funding_links":["https://github.com/sponsors/MasterQ32"],"categories":["Command Line and Argument Parser","zig"],"sub_categories":["Utility"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikskuh%2Fzig-args","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikskuh%2Fzig-args","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikskuh%2Fzig-args/lists"}