{"id":38340209,"url":"https://github.com/axieinfinity/clap-nested","last_synced_at":"2026-01-17T02:59:32.895Z","repository":{"id":38330727,"uuid":"208251070","full_name":"axieinfinity/clap-nested","owner":"axieinfinity","description":"Convenient `clap-rs` for CLI apps with multi-level subcommands.","archived":false,"fork":false,"pushed_at":"2022-06-06T21:47:40.000Z","size":48,"stargazers_count":18,"open_issues_count":3,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-01-13T09:49:45.432Z","etag":null,"topics":["clap","clap-rs","cli","command","command-line","multi-level","nested","subcommand"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/axieinfinity.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}},"created_at":"2019-09-13T11:27:23.000Z","updated_at":"2025-01-11T03:30:07.000Z","dependencies_parsed_at":"2022-07-11T02:00:41.432Z","dependency_job_id":null,"html_url":"https://github.com/axieinfinity/clap-nested","commit_stats":null,"previous_names":["skymavis/clap-nested"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/axieinfinity/clap-nested","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieinfinity%2Fclap-nested","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieinfinity%2Fclap-nested/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieinfinity%2Fclap-nested/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieinfinity%2Fclap-nested/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axieinfinity","download_url":"https://codeload.github.com/axieinfinity/clap-nested/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axieinfinity%2Fclap-nested/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T02:39:23.645Z","status":"ssl_error","status_checked_at":"2026-01-17T02:34:19.649Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["clap","clap-rs","cli","command","command-line","multi-level","nested","subcommand"],"created_at":"2026-01-17T02:59:32.813Z","updated_at":"2026-01-17T02:59:32.874Z","avatar_url":"https://github.com/axieinfinity.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clap-nested\n\n[![Cargo Crate](https://img.shields.io/crates/v/clap-nested.svg)](https://crates.io/crates/clap-nested)\n[![Docs](https://docs.rs/clap-nested/badge.svg)](https://docs.rs/clap-nested)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Build Status](https://travis-ci.com/skymavis/clap-nested.svg?branch=master)](https://travis-ci.com/skymavis/clap-nested)\n[![Coverage Status](https://coveralls.io/repos/github/skymavis/clap-nested/badge.svg?branch=master)](https://coveralls.io/github/skymavis/clap-nested?branch=master)\n\nConvenient [`clap`][clap] for CLI apps with multi-level subcommands.\n\n* [How to install?](#installation)\n* [Why `clap-nested` exists?](#why)\n* [Use cases](#use-cases)\n* [Examples](#examples)\n* [Documentation [↗]](https://docs.rs/clap-nested)\n\n## Installation\n\nAdd `clap-nested` to your `Cargo.toml`:\n\n```toml\n[dependencies]\nclap-nested = \"0.4.0\"\n```\n\n## Why?\n\nFirst of all, [`clap`][clap] is awesome!\n\nIt provides a fast, simple-to-use, and full-featured library for parsing CLI\narguments as well as subcommands.\n\nHowever, while supporting parsing nicely, [`clap`][clap] is very unopinionated\nwhen it comes to how we should structure and execute logic given provided\narguments and subcommands.\n\nThat's why we often find ourselves matching [`clap`][clap]'s parsing result with\ntens of subcommands, let alone a lot of arguments, in our CLI application which\nincludes multi-level subcommands. The bad experience also escalates quickly,\nimagine suddenly we have a lot of subcommand logic grouped under a very long\nfile.\n\nSo, we add a little sauce of opinion into [`clap`][clap] to help with that\nawkward process.\n\n## Use cases\n\nMain use cases of `clap-nested`, together with explanation, rationale,\nand related code examples are below:\n\n* [Easy subcommands and command execution](https://docs.rs/clap-nested#use-case-easy-subcommands-and-command-execution)\n* [Straightforward multi-level subcommands](https://docs.rs/clap-nested#use-case-straightforward-multi-level-subcommands)\n* [Printing help messages directly on errors](https://docs.rs/clap-nested#use-case-printing-help-messages-directly-on-errors)\n\nYou can always find more in [the documentation](https://docs.rs/clap-nested).\n\n## Examples\n\nWith `clap-nested`, we can write in a more organized way:\n\n```rust\n// foo.rs\npub fn get_cmd\u003c'a\u003e() -\u003e Command\u003c'a, str\u003e {\n    Command::new(file_stem!())\n        .description(\"Shows foo\")\n        .options(|app| {\n            app.arg(\n                Arg::with_name(\"debug\")\n                    .short(\"d\")\n                    .help(\"Prints debug information verbosely\"),\n            )\n        })\n        .runner(|args, matches| {\n            let debug = clap::value_t!(matches, \"debug\", bool).unwrap_or_default();\n            println!(\"Running foo, env = {}, debug = {}\", args, debug);\n            Ok(())\n        })\n}\n\n// bar.rs\npub fn get_cmd\u003c'a\u003e() -\u003e Command\u003c'a, str\u003e {\n    Command::new(file_stem!())\n        .description(\"Shows bar\")\n        .runner(|args, _matches| {\n            println!(\"Running bar, env = {}\", args);\n            Ok(())\n        })\n}\n\n// main.rs\nfn main() {\n    Commander::new()\n        .options(|app| {\n            app.arg(\n                Arg::with_name(\"environment\")\n                    .short(\"e\")\n                    .long(\"env\")\n                    .global(true)\n                    .takes_value(true)\n                    .value_name(\"STRING\")\n                    .help(\"Sets an environment value, defaults to \\\"dev\\\"\"),\n            )\n        })\n        .args(|_args, matches| matches.value_of(\"environment\").unwrap_or(\"dev\"))\n        .add_cmd(foo::get_cmd())\n        .add_cmd(bar::get_cmd())\n        .no_cmd(|_args, _matches| {\n            println!(\"No subcommand matched\");\n            Ok(())\n        })\n        .run();\n}\n```\n\nKindly see [`examples/clap_nested/`](examples/clap_nested/)\nand [`examples/clap.rs`](examples/clap.rs) for comparison.\n\n## License\n\n[MIT licensed](LICENSE).\n\n[clap]: https://github.com/clap-rs/clap\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxieinfinity%2Fclap-nested","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxieinfinity%2Fclap-nested","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxieinfinity%2Fclap-nested/lists"}