Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display short help menu when --help is used #4772

Merged
merged 1 commit into from
Jul 9, 2024
Merged

Display short help menu when --help is used #4772

merged 1 commit into from
Jul 9, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jul 3, 2024

I feel like I'm always drowning in the help output from uv because we have so many options.

I basically agree with the commentary in clap-rs/clap#4687 that having different behaviors for -h and --help is surprising. I think --help is more obvious for users and I want to optimize for that experience.

This roughly matches the help menus in Cargo and pip.

The uv help command can be used for long help. In #4906 and #4909 we improve that command.

Extends #4904 which adds test cases for the existing behavior.

@zanieb zanieb added the cli Related to the command line interface label Jul 3, 2024
@zanieb zanieb force-pushed the zb/cli-help branch 2 times, most recently from ab911ba to c1b0b82 Compare July 8, 2024 18:57
@zanieb zanieb changed the base branch from main to zb/cli-help-test July 8, 2024 18:57
@zanieb zanieb force-pushed the zb/cli-help branch 3 times, most recently from 0022fc8 to bdfa318 Compare July 8, 2024 19:05
crates/uv/tests/help.rs Outdated Show resolved Hide resolved
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

One other idea for "short" help information is to put the flag name and the help description on the same line, and then align the columns. For example, a selection from rg -h output:

  -i, --ignore-case               Case insensitive search.
  -v, --invert-match              Invert matching.
  -x, --line-regexp               Show matches surrounded by line boundaries.
  -m, --max-count=NUM             Limit the number of matching lines.
  --mmap                          Search with memory maps when possible.
  -U, --multiline                 Enable searching across multiple lines.
  --multiline-dotall              Make '.' match line terminators.
  --no-unicode                    Disable Unicode mode.
  --null-data                     Use NUL as a line terminator.
  -P, --pcre2                     Enable PCRE2 matching.
  --regex-size-limit=NUM          The size limit of the compiled regex.
  -S, --smart-case                Smart case search.
  --stop-on-nonmatch              Stop searching after a non-match.

This makes for very dense information display that is easy to read IMO.

The main drawback, I think, is that your descriptions have to be very short. But constraint inspires creativity. :-) And if there's a very long flag name, it can make the column alignment non-ideal. But if we can pull it off, I really like it personally.

(I am also a fan of the -h/--help distinction, but I in a sub-command architecture like we have with uv, I think command help ... is a very strong convention I've seen in many other places. So I think that's a great idea.)

Base automatically changed from zb/cli-help-test to main July 9, 2024 14:07
@zanieb
Copy link
Member Author

zanieb commented Jul 9, 2024

That'd be a nice format to explore — it'd require moving even further away from the clap defaults but I agree it'd be ideal for the short help display.

@zanieb zanieb mentioned this pull request Jul 9, 2024
zanieb added a commit that referenced this pull request Jul 9, 2024
@zanieb zanieb enabled auto-merge (squash) July 9, 2024 16:37
@zanieb zanieb merged commit 0bf562f into main Jul 9, 2024
49 checks passed
@zanieb zanieb deleted the zb/cli-help branch July 9, 2024 17:12
zanieb added a commit that referenced this pull request Jul 9, 2024
Extends #4772 

Implements `uv help` ourselves so we can do things like #4909 
Adds hints to use `uv help` for more details during short help display.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants