{"id":17251041,"url":"https://github.com/fumieval/clap4shell","last_synced_at":"2026-04-02T02:07:46.858Z","repository":{"id":57671252,"uuid":"247387598","full_name":"fumieval/clap4shell","owner":"fumieval","description":"Standalone wrapper of clap for shell scripts","archived":false,"fork":false,"pushed_at":"2025-10-20T03:24:24.000Z","size":83,"stargazers_count":35,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T07:24:03.503Z","etag":null,"topics":["options-parsing","rust","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/fumieval.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":"2020-03-15T02:25:59.000Z","updated_at":"2025-10-20T03:24:29.000Z","dependencies_parsed_at":"2024-01-17T09:29:44.150Z","dependency_job_id":null,"html_url":"https://github.com/fumieval/clap4shell","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.30000000000000004","last_synced_commit":"c5238da2db1f51f1d4ecb4576f9700a9427a3372"},"previous_names":["fumieval/urgeopts"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/fumieval/clap4shell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2Fclap4shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2Fclap4shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2Fclap4shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2Fclap4shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fumieval","download_url":"https://codeload.github.com/fumieval/clap4shell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2Fclap4shell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"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":["options-parsing","rust","shell-script"],"created_at":"2024-10-15T06:50:11.710Z","updated_at":"2026-04-02T02:07:46.825Z","avatar_url":"https://github.com/fumieval.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"clap4shell: standalone clap wrapper for shell scripts\n----\n\n[![clap4shell at crates.io](https://img.shields.io/crates/v/clap4shell.svg)](https://crates.io/crates/clap4shell)\n\n`clap4shell` is a replacement for `getopt` based on [clap](https://github.com/clap-rs/clap).\n\n`clap4shell` takes option descriptors as a YAML document from stdin, then prints the parsed result in newline-delimited `key=value` format which can be `eval`'d. See example.sh for concrete usage.\n\nInstallation\n----\n\n```sh\nnix profile install github:fumieval/clap4shell\n```\n\nUsage\n----\n\nConfigurations look like\n\n```yaml\nname: example\nbin_name: $(basename $0)\nversion: \"0.0\"\nabout: sample text\nauthor: Fumiaki Kinoshita \u003cfumiexcel@gmail.com\u003e\nargs:\n  - verbose:\n      help: verbose output\n      short: v\n      long: verbose\n  - host:\n      takes_value: true\n      long: host\n      value_name: \u003cHOST\u003e\n      help: 'host name'\n  - mode:\n      long: mode\n      help: option with a certain set of possible values\n      possible_values: [ herbivore, carnivore, omnivore ]\n  - cmd:\n      help: command\n  - arg:\n      help: command arguments\n      multiple_values: true\nsubcommands:\n  - ls:\n      about: Display a list of entities\n      args:\n        - entity:\n            multiple_values: true\n```\n\nThe schema is based on [clap_serde](https://docs.rs/clap-serde/latest/clap_serde/).\n\nThe typical usage is to embed option definitions in a shell heredoc, pass all arguments to `clap4shell` and `eval` its output:\n\n```bash\neval \"$(clap4shell \"$@\" \u003c\u003cEOT\n...\nEOT\n)\"\n```\n\nSubcommands are bound as positional parameters (`$1, $2, ...`).\n\nCompletion\n----\n\n`clap4shell-completion \u003cshell\u003e -o \u003cpath\u003e` subcommand generates an autocompletion script for `\u003cshell\u003e` and writes the script to `path`.\n\n```sh\nclap4shell clap4shell-completion bash -o ./bash-completion.sh \u003c definition.yaml\n```\n\nWhen \"-o\" is omitted, it prints an echo command that prints the script, followed by `exit 0`. Therefore this feature can be used transparently even if the output of `clap4shell` is passed to `eval`.\n\n```\n./foo.sh clap4shell-completion \u003e ~/.zsh/_foo.sh\n```\n\nNotes\n----\n\nI intentionally avoided using `clap::App::from_yaml` because the redundancy of the YAML representation and difficulty of debugging panics.\nThe YAML interface is being deprecated: https://github.com/clap-rs/clap/issues/3087","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffumieval%2Fclap4shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffumieval%2Fclap4shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffumieval%2Fclap4shell/lists"}