Provide long help via rv help, remove per-command help subcommands#717
Open
carl wants to merge 1 commit into
Open
Provide long help via rv help, remove per-command help subcommands#717carl wants to merge 1 commit into
rv help, remove per-command help subcommands#717carl wants to merge 1 commit into
Conversation
Help is now requested in two consistent ways: - `rv ... -h` / `rv ... --help` show short help (unchanged) - `rv help [NAME]` shows long help for the targeted command The per-command `rv NAME help` forms (e.g. `rv ruby help pin`) are removed by disabling the auto-generated `help` subcommand on each command group, so there is a single way to ask for full help. The top-level `help` subcommand is preserved, so `rv help ruby pin` still works. Fixes spinel-coop#431
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #431.
What this does
Help is now requested in two consistent ways:
rv … -h/rv … --helpshow short help (unchanged)rv help [NAME]shows long help for the targeted commandThe per-command
rv NAME helpforms (e.g.rv ruby help pin) are removed by disabling the auto-generatedhelpsubcommand on each command group (ruby,tool,cache,self,shell), so there is a single way to ask for full help. The top-levelhelpsubcommand is preserved, sorv help ruby pinstill works.This addresses the two open checkboxes in #431:
rv help [NAME]shows long helprv NAME helpremovedBefore / after
rv … -h/--helprv help [NAME]rv ruby help pinrv ruby -hcommand listhelphelprv help ruby pin(top level)Implementation
Five one-line additions of
#[command(disable_help_subcommand = true)]to the command-group arg structs. clap'shelpsubcommand renders long help (write_long_help) while-h/--helpare mapped toHelpShort, so the long-vs-short routing already follows from keeping the top-level help subcommand and removing the nested ones.Tests
crates/rv/tests/integration_tests/main.rs:test_help_subcommand_shows_long_help—rv helpexpands enum descriptions;rv -hdoes nottest_help_subcommand_shows_nested_command_help—rv help ruby pinstill prints the command's helptest_help_subcommand_removed_from_command_groups—rv {ruby,tool,cache,self} help→unrecognized subcommand 'help'test_help_subcommand_removed_from_shell—rv shell helpfailstest_help_not_advertised_as_command_group_subcommand—helpno longer appears in the-hcommand listing forruby/tool/cache/selfEach behavior-changing test was confirmed to fail against the pre-change source. Full suite (
cargo nextest run -p rv),cargo fmt --all -- --check, andcargo clippy -p rv --all-targetsall pass.Notes for reviewers (out of scope / open question)
help. On commands whose leaf takes a positional,helpis consumed as a value rather than rejected:rv ruby pin helppins the version to the literal"help", andrv shell helperrors asinvalid value 'help' for '[SHELL]'rather thanunrecognized subcommand 'help'. These aren't help subcommands, so they're untouched by this change. Happy to address separately if you'd like them to error explicitly.long_aboutprose authored. This PR makesrv help [NAME]route to long help, but long help only differs visibly where an arg carries rich metadata (e.g.--color's enum descriptions). If you want genuinely richer per-command long help, that's a larger, separate effort I left out here. Let me know if it should be part of this issue.