feat(parse): parse Args without an enclosing CLI - #1419
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe PR adds standalone parsing functions for derived argument types, re-exports them, documents their use, and tests successful parsing, subcommands, help, invalid choices, and missing required arguments. ChangesStandalone argument parsing
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Caller
participant parse_args_from
participant Parser
participant CommandArgs
Caller->>parse_args_from: provide argv
parse_args_from->>Parser: parse T::COMMAND
Parser-->>parse_args_from: parsed arguments or error
parse_args_from->>CommandArgs: run T::check and T::build
CommandArgs-->>Caller: return parsed value or error
Merge Risk: ⚪ Minimal · up to The new standalone parsing APIs are covered for normal values, subcommands, defaults, and standard errors, with no current merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Instruction counts
No instruction-count regression above 1%. Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes. Shadow comparisonParsing
|
### 🚀 Features - **(help)** allow remapping semantic colours on Style by [@lu-zero](https://github.com/lu-zero) in [#1414](#1414) - **(parse)** add opt-in default-subcommand flag routing by [@jdx](https://github.com/jdx) in [#1413](#1413) - **(parse)** parse Args without an enclosing CLI by [@jdx](https://github.com/jdx) in [#1419](#1419) ### 🐛 Bug Fixes - **(bash)** preserve colon-prefixed completion words by [@jdx](https://github.com/jdx) in [#1405](#1405) ### 📚 Documentation - write PR titles and descriptions for release notes by [@jdx](https://github.com/jdx) in [#1415](#1415) ### ⚡ Performance - **(cli)** shrink help sorting without allocating cached keys by [@jdx](https://github.com/jdx) in [#1396](#1396) - **(cli)** make advanced help and runtime spec serialization optional by [@jdx](https://github.com/jdx) in [#1399](#1399) - **(cli)** share help sorting and skip unused rendering work by [@jdx](https://github.com/jdx) in [#1400](#1400) - **(cli)** avoid color analysis for plain help by [@jdx](https://github.com/jdx) in [#1401](#1401) ### 🔍 Other Changes - **(ci)** use self-repository workflow references by [@jdx](https://github.com/jdx) in [#1409](#1409) ### 📦️ Dependency Updates - lock file maintenance by [@renovate[bot]](https://github.com/renovate[bot]) in [#1398](#1398) - update jdx/renovate-config digest to 8cabc2e by [@renovate[bot]](https://github.com/renovate[bot]) in [#1406](#1406) - update zizmorcore/zizmor-action action to v0.6.3 by [@renovate[bot]](https://github.com/renovate[bot]) in [#1403](#1403) - update dependency go to v1.27.1 by [@renovate[bot]](https://github.com/renovate[bot]) in [#1407](#1407) - update actions/deploy-pages action to v5 by [@renovate[bot]](https://github.com/renovate[bot]) in [#1404](#1404) - update communique to v1.4.0 by [@jdx](https://github.com/jdx) in [#1416](#1416) ### New Contributors - @lu-zero made their first contribution in [#1414](#1414)
Adapters and embedded command surfaces can now parse one derived
Argstype without constructing or parsing the application’s root CLI. This lets callers reuse the command’s compiled flags, positional arguments, defaults, validation, subcommand routing, and typed construction directly.The second form follows the full-argv convention and strips argv0. Both return ordinary usage parse errors, including help requests, for the selected command.
Validation:
mise run ci(Rust workspace tests and doctests, Clippy, formatting, semver checks, Prettier, and Go tests).AI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable.
Note
Low Risk
Additive public API on the existing parser path; behavior is covered by new integration tests with no changes to root CLI parsing.
Overview
Adds
parse_args_fromandparse_args_from_argvso a derivedCommandArgs/Argstype can be parsed without a rootCli. Parsing starts at that command’s tables (flags, positionals, defaults, validation, nested subcommands) and returns the sameErrorvariants as full-app parsing, including help, version, and missing-args help.parse_args_fromtreats the slice as that command’s words only;parse_args_from_argvstrips argv0 first. Both are re-exported fromusage-rs(viausage_argv) behind thespecfeature. Docs and facade tests cover success paths, choices, help, and subcommand routing.Reviewed by Cursor Bugbot for commit 9149f89. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Documentation
Tests