{"id":13739801,"url":"https://github.com/winksaville/zig-parse-args","last_synced_at":"2026-01-29T05:09:01.430Z","repository":{"id":77462887,"uuid":"147274030","full_name":"winksaville/zig-parse-args","owner":"winksaville","description":"Parse command line arguments.","archived":false,"fork":false,"pushed_at":"2018-11-17T01:18:57.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-15T09:44:03.681Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/winksaville.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}},"created_at":"2018-09-04T01:57:15.000Z","updated_at":"2024-10-24T21:53:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e7b6560-0e6e-449c-8378-1bc954aa3bfb","html_url":"https://github.com/winksaville/zig-parse-args","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/winksaville%2Fzig-parse-args","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winksaville%2Fzig-parse-args/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winksaville%2Fzig-parse-args/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winksaville%2Fzig-parse-args/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/winksaville","download_url":"https://codeload.github.com/winksaville/zig-parse-args/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253135552,"owners_count":21859666,"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":[],"created_at":"2024-08-03T04:00:37.764Z","updated_at":"2026-01-29T05:09:01.382Z","avatar_url":"https://github.com/winksaville.png","language":null,"funding_links":[],"categories":["Applications","Parser"],"sub_categories":[],"readme":"# Zig parse arguments\n\nI don't like this that much, I think instead of parsing\nthe arguments directly to Types it should probably just\nstay as strings and then any type specific parsing is done\nlater. This is what src-self-hosted/arg.zig does and overall\nsrc-self-hosted/arg.zig is better execpt I like \"name=value\"\npairs rather than \"--flag value\" syntax.\n\nAn interesting technique in src-self-host/arg.zig is creating\na struct with different constructors initializing fields\ndifferently without using \"comptime T: type\". This allows\nstraight forward creation of arrays without the need for tagged\nunions or a \"common interface\" and @fieldParentPtr.\n\nParseNumber seems pretty good with the optional \"\\_\" seperator.\n\n# Improvements:\n\nAllow addition of different \"types\" at compile time and\nmaybe runtime. Right now a tagged union ArgUnionFields is used\nto manage different types of data that can be parsed. For new\n\"types\" to be added ArgUnionFields and the appropriate code paths need\nto be updated. It would be nicer if the programmer could add them\nat comptime at a minimum and possibly at runtime.\n\nin the use-ArgRecCommon I tried using the \"common interface\" and\n@fieldParentPtr technique but that really didn't help, at least I\ncouldn't make it really extensible at compile time.\n\n# Current\n\nParse the parameters passed on the command line\nand available in osArgIter: std.os.ArgIterator and\nwell as my own ArgIteratorTest. Both are avaiable via\nthe wrapper ArgIter:\n\n    ArgIter.initOsArgIter() Self\n    ArgIter.initTestArgIter(args: []const []const u8) Self\n\nBesides the iterator with the command line arguments you\nneed to create an ArrayList(ArgRec) and initialize the list\nwith a \"prototype\" for each possible command line argument.\n\nSee the tests in parse_args.zig and test_app.zig for details,\nI'm not going to add doc's here yet, because I don't like the\nAPI. I need to make the improvments mentioned below.\n\n## Test\n```bash\n$ zig test parse_args.zig\n```\n\n## Clean\nRemove `zig-cache/` directory\n```bash\n$ rm -rf test ./zig-cache/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinksaville%2Fzig-parse-args","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinksaville%2Fzig-parse-args","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinksaville%2Fzig-parse-args/lists"}