{"id":13533126,"url":"https://github.com/sam701/zig-cli","last_synced_at":"2025-08-19T11:08:25.582Z","repository":{"id":46326070,"uuid":"468036481","full_name":"sam701/zig-cli","owner":"sam701","description":"A simple package for building command line apps in Zig","archived":false,"fork":false,"pushed_at":"2025-08-11T11:24:54.000Z","size":162,"stargazers_count":292,"open_issues_count":7,"forks_count":31,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-11T13:14:27.313Z","etag":null,"topics":["argument-parser","cli","command-line","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sam701.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":"2022-03-09T17:55:00.000Z","updated_at":"2025-08-02T11:25:49.000Z","dependencies_parsed_at":"2025-05-29T21:31:22.189Z","dependency_job_id":"e78d1d92-2d8b-41b8-ac9f-6c3cf499b425","html_url":"https://github.com/sam701/zig-cli","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/sam701/zig-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam701%2Fzig-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam701%2Fzig-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam701%2Fzig-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam701%2Fzig-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sam701","download_url":"https://codeload.github.com/sam701/zig-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sam701%2Fzig-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271143380,"owners_count":24706345,"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-08-19T02:00:09.176Z","response_time":63,"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":["argument-parser","cli","command-line","zig-package","ziglang"],"created_at":"2024-08-01T07:01:16.791Z","updated_at":"2025-08-19T11:08:25.573Z","avatar_url":"https://github.com/sam701.png","language":"Zig","readme":"# ZIG-CLI\n[![Zig Docs](https://img.shields.io/badge/docs-zig-%23f7a41d)](https://sam701.github.io/zig-cli)\n\n\nA simple package for building command line apps in Zig.\n\nInspired by [urfave/cli](https://github.com/urfave/cli) Go package.\n\n## Features\n* command line arguments are parsed into zig values\n* long and short options: `--option1`, `-o`\n* optional `=` sign: `--address=127.0.0.1` equals `--address 127.0.0.1`\n* concatenated short options: `-a -b -c` equals `-abc`\n* subcommands: `command1 -option1 subcommand2 -option2`\n* multiple option values: `--opt val1 --opt val2 --opt val3`\n* enums as option values: `--opt EnumValue1`\n* options value can be read from environment variables with a configured prefix\n* positional arguments can be mixed with options: `--opt1 val1 arg1 -v`\n* stops option parsing after `--`: `command -- --abc` will consider `--abc` as a positional argument to `command`.\n* errors on missing required options: `ERROR: option 'ip' is required`\n* prints help with `--help`\n* colored help messages when TTY is attached\n\n## Usage\n```zig\nconst std = @import(\"std\");\nconst cli = @import(\"cli\");\n\n// Define a configuration structure with default values.\nvar config = struct {\n    host: []const u8 = \"localhost\",\n    port: u16 = undefined,\n}{};\n\npub fn main() !void {\n    var r = try cli.AppRunner.init(std.heap.page_allocator);\n\n    // Create an App with a command named \"short\" that takes host and port options.\n    const app = cli.App{\n        .command = cli.Command{\n            .name = \"short\",\n            .options = try r.allocOptions(\u0026.{\n                // Define an Option for the \"host\" command-line argument.\n                .{\n                    .long_name = \"host\",\n                    .help = \"host to listen on\",\n                    .value_ref = r.mkRef(\u0026config.host),\n                },\n\n                // Define an Option for the \"port\" command-line argument.\n                .{\n                    .long_name = \"port\",\n                    .help = \"port to bind to\",\n                    .required = true,\n                    .value_ref = r.mkRef(\u0026config.port),\n                },\n            }),\n            .target = cli.CommandTarget{\n                .action = cli.CommandAction{ .exec = run_server },\n            },\n        },\n    };\n    return r.run(\u0026app);\n}\n\n// Action function to execute when the \"short\" command is invoked.\nfn run_server() !void {\n    // Log a debug message indicating the server is listening on the specified host and port.\n    std.log.debug(\"server is listening on {s}:{d}\", .{ config.host, config.port });\n}\n```\n\n### Using with the Zig package manager\nAdd `cli` to your `build.zig.zon`\n```\nzig fetch --save git+https://github.com/sam701/zig-cli\n```\nSee the [`standalone`](./examples/standalone) example in the `examples` folder.\n\n## Printing help\nSee [`simple.zig`](./examples/simple.zig)\n\n```\n$ ./zig-out/bin/simple sub1 --help\nUSAGE:\n  simple sub1 [OPTIONS]\n\nanother awesome command\n\nthis is my awesome multiline description.\nThis is already line 2.\nAnd this is line 3.\n\nCOMMANDS:\n  sub2   sub2 help\n\nOPTIONS:\n  -i, --ip \u003cIP\u003e         this is the IP address\n      --int \u003cVALUE\u003e     this is an int\n      --bool            this is a bool\n      --float \u003cVALUE\u003e   this is a float\n  -h, --help            Prints help information\n```\n\n## License\nMIT\n","funding_links":[],"categories":["Applications","Zig","cli","Language Essentials","[Zig](https://ziglang.org/)"],"sub_categories":["Command Line and Argument Parser","Useful awesome list for Ruby cli"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsam701%2Fzig-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsam701%2Fzig-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsam701%2Fzig-cli/lists"}