{"id":30141870,"url":"https://github.com/kingrashy12/ziglet","last_synced_at":"2026-05-26T20:31:24.735Z","repository":{"id":304419291,"uuid":"1018664024","full_name":"Kingrashy12/ziglet","owner":"Kingrashy12","description":"A concise and powerful CLI builder for Zig.","archived":false,"fork":false,"pushed_at":"2026-04-08T01:03:32.000Z","size":105,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-08T03:06:18.394Z","etag":null,"topics":["cli-builder","zig-package"],"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/Kingrashy12.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-12T18:52:29.000Z","updated_at":"2026-04-08T01:03:24.000Z","dependencies_parsed_at":"2026-04-08T03:03:04.233Z","dependency_job_id":null,"html_url":"https://github.com/Kingrashy12/ziglet","commit_stats":null,"previous_names":["kingrashy12/ziglet"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/Kingrashy12/ziglet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kingrashy12%2Fziglet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kingrashy12%2Fziglet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kingrashy12%2Fziglet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kingrashy12%2Fziglet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kingrashy12","download_url":"https://codeload.github.com/Kingrashy12/ziglet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kingrashy12%2Fziglet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33538659,"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":"ssl_error","status_checked_at":"2026-05-26T15:22:15.568Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cli-builder","zig-package"],"created_at":"2025-08-11T05:19:57.247Z","updated_at":"2026-05-26T20:31:24.730Z","avatar_url":"https://github.com/Kingrashy12.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ziglet\n\nA concise and powerful CLI builder for Zig.\n\n## ✨ Features\n\n- Add and organize custom commands with ease\n- Execute commands with `parse` built into Ziglet\n- Minimal dependencies, maximum speed\n- Built in Zig for clarity, performance, and control\n\n## 📚 How to Use\n\n1. Fetch the package:\n\n```bash\nzig fetch --save git+https://github.com/Kingrashy12/ziglet\n```\n\n2. Add the module to your `build.zig`:\n\n```zig\n  // Add the ziglet dependency\n  const ziglet = b.dependency(\"ziglet\", .{});\n\n  // Add the ziglet module to the executable\n  exe.root_module.addImport(\"ziglet\", ziglet.module(\"ziglet\"));\n```\n\n3. Import and use in your code:\n\n### Basic Usage\n\n```zig\nconst std = @import(\"std\");\nconst ziglet = @import(\"ziglet\");\nconst CommandContext = ziglet.BuilderTypes.CommandContext;\nconst CLIBuilder = ziglet.CLIBuilder;\n\npub fn main(init: std.process.Init) !void {\n    const arena = init.arena;\n    const allocator = init.gpa;\n    const args = try init.minimal.args.toSlice(arena.allocator());\n\n    var cli = CLIBuilder.init(allocator, init, \"my-cli\", \"0.1.0\", \"A simple CLI example\");\n    defer cli.deinit();\n\n    // Add a command with options\n    cli.addCommand(.{\n        .name = \"greet\",\n        .description = \"Greet someone\",\n        .action = greet,\n        .options = cli.defOptions(\u0026.{.{\n            .name = \"name\",\n            .alias = \"n\",\n            .type = .string,\n            .required = true,\n            .description = \"Name to greet\",\n        }}),\n    });\n\n    try cli.parse(args, null);\n}\n\nfn greet(ctx: CommandContext) !void {\n    const name = ctx.options.get(\"name\");\n\n    if (name) |n| {\n        std.debug.print(\"Hello, {s}!\\n\", .{n.string});\n    }\n}\n```\n\n### Global Options\n\nZiglet supports global options that apply to all commands:\n\n```zig\n// ... (same setup as above)\n\nvar cli = CLIBuilder.init(allocator, init, \"example-cli\", \"1.0.0\", \"A CLI with global options\");\ndefer cli.deinit();\n\n// Enable global options (adds --help and --version automatically)\ncli.setGlobalOptions();\n\n// Add a global option\ncli.option(.{\n    .alias = \"v\",\n    .name = \"verbose\",\n    .type = .bool,\n    .description = \"Enable verbose output\",\n});\n\n// Add commands that can access global options\ncli.addCommand(.{\n    .name = \"greet\",\n    .description = \"Greet someone\",\n    .action = greet,\n    .options = cli.defOptions(\u0026.{.{\n        .name = \"name\",\n        .alias = \"n\",\n        .type = .string,\n        .required = true,\n        .description = \"Name to greet\",\n    }}),\n});\n\ntry cli.parse(args, null);\n\n// In your action function, access both global and command options\nfn greet(ctx: CommandContext) !void {\n    const verbose = ctx.options.get(\"verbose\");\n    const name = ctx.options.get(\"name\");\n\n    if (verbose) |v| if (v.bool) {\n        std.debug.print(\"Verbose mode enabled.\\n\", .{});\n    }\n\n    if (name) |n| {\n        std.debug.print(\"Hello, {s}!\\n\", .{n.string});\n    }\n}\n```\n\n### Factory Pattern (Fluent API)\n\nFor a more fluent and readable way to build commands:\n\n```zig\n// ... (same setup as above)\n\nvar cli = CLIBuilder.init(allocator, init,\"my-cli\", \"0.1.0\", \"Factory builder example\");\ndefer cli.deinit();\n\ncli.setGlobalOptions();\n\n// Global option\n_ = cli.option(.{\n    .alias = \"v\",\n    .name = \"verbose\",\n    .type = .bool,\n    .description = \"Enable verbose output\",\n});\n\n// Build commands using fluent API\nconst greet_cmd = cli.command(\"greet\", \"Greet someone\")\n    .option(.{\n        .alias = \"n\",\n        .name = \"name\",\n        .required = true,\n        .type = .string,\n        .description = \"Name to greet\",\n    })\n    .action(greet)\n    .finalize();\n\nconst calc_cmd = cli.command(\"calc\", \"Calculate sum of two numbers\")\n    .option(.{\n        .alias = \"a\",\n        .name = \"a\",\n        .required = true,\n        .type = .number,\n        .description = \"First number\",\n    })\n    .option(.{\n        .alias = \"b\",\n        .name = \"b\",\n        .required = true,\n        .type = .number,\n        .description = \"Second number\",\n    })\n    .action(calc)\n    .finalize();\n\n// Command without options\n_ = cli.command(\"status\", \"Show status\")\n    .action(status)\n    .finalize();\n\n// Parse with factory commands\ntry cli.parse(args, \u0026.{ greet_cmd, calc_cmd });\n\nfn greet(ctx: CommandContext) !void {\n    const name = ctx.options.get(\"name\");\n    std.debug.print(\"Greeting someone from '{s}'.\\n\", .{ctx.name});\n\n    if (name) |n| {\n        std.debug.print(\"Hello, {s}!\\n\", .{n.string});\n    }\n}\n\nfn calc(ctx: CommandContext) !void {\n    const a_opt = ctx.options.get(\"a\");\n    const b_opt = ctx.options.get(\"b\");\n\n    if (a_opt) |a| if (b_opt) |b| {\n        const sum = a.number + b.number;\n        std.debug.print(\"Sum: {d}\\n\", .{sum});\n    }\n}\n\nfn status(ctx: CommandContext) !void {\n    _ = ctx;\n    std.debug.print(\"System status: All good!\\n\", .{});\n}\n```\n\n## 📖 Examples\n\nFor runnable examples, see the [examples/](examples/) directory:\n\n- [`examples/plain.zig`](examples/plain.zig) - Comprehensive example with multiple commands, global options, and different option types\n- [`examples/factory.zig`](examples/factory.zig) - Demonstrates the fluent factory pattern for building commands\n\n## 🤝 Contributing\n\nWant to make Ziglet even snappier? Feel free to open issues, suggest features, or submit pull requests. Let’s build something sharp together.\n\n## 📄 License\n\nMIT – free to use, modify, and share.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingrashy12%2Fziglet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingrashy12%2Fziglet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingrashy12%2Fziglet/lists"}