{"id":15099901,"url":"https://github.com/jiacai2050/simargs","last_synced_at":"2025-10-08T05:31:18.302Z","repository":{"id":64537024,"uuid":"575015005","full_name":"jiacai2050/simargs","owner":"jiacai2050","description":"A simple, opinionated, struct-based argument parser in Zig.","archived":true,"fork":false,"pushed_at":"2023-10-21T05:10:56.000Z","size":61,"stargazers_count":56,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-02T07:04:43.489Z","etag":null,"topics":["argument-parser","argument-parsing","cli","zig","zig-library","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/jiacai2050.png","metadata":{"files":{"readme":"README.org","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}},"created_at":"2022-12-06T15:09:10.000Z","updated_at":"2024-04-08T16:00:13.000Z","dependencies_parsed_at":"2023-01-30T06:10:12.705Z","dependency_job_id":"8835474e-7e04-4ae2-a89b-f31fdbc3e84d","html_url":"https://github.com/jiacai2050/simargs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiacai2050%2Fsimargs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiacai2050%2Fsimargs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiacai2050%2Fsimargs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiacai2050%2Fsimargs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiacai2050","download_url":"https://codeload.github.com/jiacai2050/simargs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235683861,"owners_count":19029079,"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":["argument-parser","argument-parsing","cli","zig","zig-library","ziglang"],"created_at":"2024-09-25T17:40:36.999Z","updated_at":"2025-10-08T05:31:12.986Z","avatar_url":"https://github.com/jiacai2050.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE: SimArgs\n#+DATE: 2022-12-07T22:56:41+0800\n#+LASTMOD: 2023-10-21T13:10:50+0800\n#+AUTHOR: Jiacai Liu\n#+EMAIL: dev@liujiacai.net\n#+OPTIONS: toc:nil num:nil\n#+STARTUP: content\n\n#+begin_quote\nNotice: this repo has moved to https://github.com/jiacai2050/zigcli.\n#+end_quote\n\n[[https://github.com/jiacai2050/simargs/actions/workflows/CI.yml][https://github.com/jiacai2050/simargs/actions/workflows/CI.yml/badge.svg]]\n\nA simple, opinionated, struct-based argument parser in Zig, taking full advantage of [[https://kristoff.it/blog/what-is-zig-comptime/][comptime]].\n\nBlog post explaining how =simargs= is implemented:\n- [[https://en.liujiacai.net/2022/12/14/argparser-in-zig/][What I learn by implementing argparser in Zig]]\n* Features\n- Supported data type:\n  - All [[https://ziglang.org/documentation/master/#Primitive-Types][primitive types]], such as =i8=, =f32=, =bool=\n  - =[]const u8=\n  - =Enum=\n- Optional fields and fields with default value mean they are optional arguments\n- Use =comptime= as possible as I can\n- Provide =print_help()= out of the box\n* Usage\nSee [[file:demo.zig]]\n\n#+begin_src bash :results verbatim :exports both\n# Run demo\nzig build \u0026\u0026 ./zig-out/bin/demo -o /tmp/a.out --user-agent Firefox hello world 2\u003e\u00261\n#+end_src\n\n#+RESULTS:\n#+begin_example\n------------------------------Program------------------------------\n./zig-out/bin/demo\n\n------------------------------Arguments------------------------------\n   verbose: null\nuser-agent: demo.main__struct_1677.main__struct_1677__enum_1777.Firefox\n   timeout: 30\n    output: /tmp/a.out\n      help: false\n\n------------------------------Positionals------------------------------\n1: hello\n2: world\n\n------------------------------print_help------------------------------\n USAGE:\n     ./zig-out/bin/demo [OPTIONS] [--] [file]\n\n OPTIONS:\n\t-v, --verbose                     Make the operation more talkative\n\t-A, --user-agent STRING            (valid: Chrome|Firefox|Safari)(default: Firefox)\n\t    --timeout INTEGER             Max time this request can cost(default: 30)\n\t-o, --output STRING               Write to file instead of stdout(required)\n\t-h, --help\n#+end_example\n* Install\nFirst add =simargs= to =build.zig.zon= of your project\n#+begin_src zig\n.{\n    .name = \"..\",\n    .version = \"..\",\n    .dependencies = .{\n        .simargs = .{\n            .url = \"https://github.com/jiacai2050/simargs/archive/0a1a2afd072cc915009a063075743192fc6b1fd5.tar.gz\",\n            .hash = \"1220a6554eccb2e9a9d7d63047e062314851ffd11315b9e6d1b5e06a9dde3275f150\",\n        },\n    },\n}\n\n#+end_src\nThen addModule in =build.zig=\n#+begin_src zig\n    const dep_simargs = b.dependency(\"simargs\", .{\n        .target = target,\n        .optimize = optimize,\n    });\n    exe.addModule(\"simargs\", dep_simargs.module(\"simargs\"));\n#+end_src\n\nFinally import like this in your Zig code:\n#+begin_src zig\nconst simargs = @import(\"simargs\");\n#+end_src\n\n* Who's Using\n- [[https://github.com/jiacai2050/zigcli][jiacai2050/zigcli: Command line programs written in Zig.]]\n\nIf you’d like to be added to this list, welcome to [[https://github.com/jiacai2050/simargs/pulls][open a PR]].\n* Acknowledgment\nWhen implement =simargs=, I refer following projects to learn how to write\nidiomatic Zig code. Big Thanks!\n- [[https://github.com/MasterQ32/zig-args/][MasterQ32/zig-args]]\n- [[https://github.com/Hejsil/zig-clap][Hejsil/zig-clap]]\n- [[https://github.com/evangrayk/zig-argparse][evangrayk/zig-argparse]]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiacai2050%2Fsimargs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiacai2050%2Fsimargs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiacai2050%2Fsimargs/lists"}