{"id":13755892,"url":"https://github.com/smores56/weaver","last_synced_at":"2026-01-01T22:31:33.047Z","repository":{"id":231294115,"uuid":"780877914","full_name":"smores56/weaver","owner":"smores56","description":"An ergonomic command-line argument parser for the Roc language.","archived":false,"fork":false,"pushed_at":"2025-01-24T18:25:35.000Z","size":172,"stargazers_count":50,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-09T03:33:42.361Z","etag":null,"topics":["argument-parser","cli","roc-lang"],"latest_commit_sha":null,"homepage":"https://smores56.github.io/weaver/Cli","language":"Roc","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smores56.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-04-02T10:29:49.000Z","updated_at":"2025-01-24T18:25:27.000Z","dependencies_parsed_at":"2024-08-03T11:01:31.573Z","dependency_job_id":"569cf130-37f9-4584-bd20-b13273899be1","html_url":"https://github.com/smores56/weaver","commit_stats":null,"previous_names":["smores56/roclap","smores56/weaver"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smores56%2Fweaver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smores56%2Fweaver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smores56%2Fweaver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smores56%2Fweaver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smores56","download_url":"https://codeload.github.com/smores56/weaver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243475373,"owners_count":20296712,"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","cli","roc-lang"],"created_at":"2024-08-03T11:00:32.279Z","updated_at":"2026-01-01T22:31:27.996Z","avatar_url":"https://github.com/smores56.png","language":"Roc","funding_links":[],"categories":["Roc Packages 📦"],"sub_categories":[],"readme":"Weaver\n======\n\nAn ergonomic command-line argument parser for the Roc language.\n\nThis library aims to provide a convenient interface for parsing CLI arguments\ninto structured data, in the style of Rust's [clap](https://github.com/clap-rs/clap).\nWithout code generation at compile time, the closest we can get in Roc is the use of the\n[record builder syntax](https://www.roc-lang.org/examples/RecordBuilder/README.html).\nThis allows us to build our config and parser at the same time, in a type-safe way!\n\nRead the documentation at \u003chttps://smores56.github.io/weaver/Cli/\u003e.\n\n## Status\n\nThis library is ready to parse your args today, but I'm always looking for more testing\nfrom the community! Feel free to open a GitHub issue if there's a feature you're missing\nfrom another CLI parsing library that you think would fit well in Weaver's nest.\n\n## Example\n\n```roc\napp [main!] {\n    pf: platform \"\u003clatest from https://github.com/roc-lang/basic-cli/releases\u003e\",\n    weaver: \"\u003clatest from https://github.com/smores56/weaver/releases\u003e\",\n}\n\nimport pf.Arg\nimport pf.Stdout\nimport weaver.Opt\nimport weaver.Cli\nimport weaver.Param\n\nmain! = |args|\n    data =\n        Cli.parse_or_display_message(cli_parser, args, Arg.to_os_raw)\n        |\u003e Result.on_err!(|message|\n            Stdout.line!(message)?\n            Err(Exit(1, \"\"))\n        )\n\n    Stdout.line!(\"Successfully parsed! Here's what I got:\")?\n    Stdout.line!(\"\")?\n    Stdout.line!(Inspect.to_str(data))?\n\n    Ok({})\n\ncli_parser =\n    { Cli.weave \u003c-\n        alpha: Opt.u64({ short: \"a\", help: \"Set the alpha level.\" }),\n        force: Opt.flag({ short: \"f\", help: \"Force the task to complete.\" }),\n        file: Param.maybe_str({ name: \"file\", help: \"The file to process.\" }),\n        files: Param.str_list({ name: \"files\", help: \"The rest of the files.\" }),\n    }\n    |\u003e Cli.finish({\n        name: \"basic\",\n        version: \"v0.1.0\",\n        authors: [\"Some One \u003csome.one@mail.com\u003e\"],\n        description: \"This is a basic example of what you can build with Weaver. You get safe parsing, useful error messages, and help pages all for free!\",\n    })\n    |\u003e Cli.assert_valid\n```\n\nAnd here's us calling the above example from the command line:\n\n```console\n$ roc examples/basic.roc -- file1.txt file2.txt -f -a 123\nSuccessfully parsed! Here's what I got:\n\n{alpha: 123, file: (Ok \"file1.txt\"), files: [\"file2.txt\"], force: Bool.true}\n\n$ roc readme.roc -- --help\nbasic v0.0.1\nSome One \u003csome.one@mail.com\u003e\n\nThis is a basic example of what you can build with Weaver. You get safe parsing, useful error messages, and help pages all for free!\n\nUsage:\n  basic -a NUM [options] \u003cfile\u003e \u003cfiles...\u003e\n\nArguments:\n  \u003cfile\u003e      The file to process.\n  \u003cfiles...\u003e  The rest of the files.\n\nOptions:\n  -a NUM         Set the alpha level.\n  -f             Force the task to complete.\n  -h, --help     Show this help page.\n  -V, --version  Show the version.\n```\n\nThere are also some examples in the [examples](./examples) directory that are more\nfeature-complete, with more to come as this library matures.\n\n## Roadmap\n\nNow that an initial release has happened, these are some ideas I have for future development:\n\n- [ ] Optionally set `{ group ?? Str }` per option so they are visually grouped in the help page\n- [ ] Completion generation for popular shells (e.g. Bash, Zsh, Fish, etc.)\n- [X] Add terminal escape sequences to generated messages for prettier help/usage text formatting (currently working, but could be nicer/more configurable)\n- [ ] add convenient CLI platform wrappers (e.g. parse, or print help and exit) for use with module params\n- [X] Clean up default parameter code if we can elide different fields on the same record type in different places (not currently allowed)\n- [ ] Add more testing (always)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmores56%2Fweaver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmores56%2Fweaver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmores56%2Fweaver/lists"}