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

Short/long help distinction seems unclear to the end-user #1015

Closed
8573 opened this issue Jul 29, 2017 · 10 comments · Fixed by #4159
Closed

Short/long help distinction seems unclear to the end-user #1015

8573 opened this issue Jul 29, 2017 · 10 comments · Fixed by #4159
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing

Comments

@8573
Copy link

8573 commented Jul 29, 2017

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

This default help message, produced by clap version 2.25.1, seems to
me to imply that -h and --help do the same thing, when they don't
necessarily. For Args defined with both help and long_help,
--help may provide much more information than -h, but as far as I
can tell there is nothing to make the end-user aware of this, which
seems problematic to me.

@kbknapp
Copy link
Member

kbknapp commented Jul 29, 2017

True, but then again they might do the same thing. Programs that opt in to differences (via Arg::long_help and friends) can also change the default help message to reflect those differences, such as how ripgrep does it.

I do believe this should be marked as a documentation issue.

@kbknapp kbknapp added A-docs Area: documentation, including docs.rs, readme, examples, etc... D: easy E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Jul 29, 2017
@8573
Copy link
Author

8573 commented Jul 29, 2017

True, but then again they might do the same thing. Programs that
opt in to differences (via Arg::long_help and friends) can also
change the default help message to reflect those differences, such as how
ripgrep
does it.

Oh huh, I'd never noticed that in ripgrep; thanks for the tip.

I do believe this should be marked as a documentation issue.

Okay.

@kbknapp kbknapp added A-help Area: documentation, including docs.rs, readme, examples, etc... P3: want to have E-easy Call for participation: Experience needed to fix: Easy / not much labels Jul 22, 2018
@kbknapp kbknapp added this to the v3-alpha.1 milestone Jul 22, 2018
@pksunkara pksunkara modified the milestones: v3-alpha.2, v3.0 Feb 1, 2020
@pksunkara pksunkara modified the milestones: 3.0, 3.1 Feb 28, 2021
@pksunkara pksunkara removed the W: 3.x label Aug 13, 2021
@martinvonz
Copy link
Contributor

Is it reasonable for clap to split up -h and --help into two arguments, so they appear on two lines in the help text?

I think much of the problem is that they're presented as -h, --help, which made at least me (as a user) think that they're just aliases. I'm a little worried that, even if I (as a developer) add a custom help message with App::help_message() to clarify that the two flags are different, my users might make not even read that because they see -h, --help and assume they're aliases without reading the description.

martinvonz added a commit to martinvonz/jj that referenced this issue Sep 8, 2021
It turns out that `--help` provides a longer version of the help text
than `-h` does. I only discovered that because I was wondering what
the difference between `clap::App::about()` and
`clap::App::long_about()` was. There's clap-rs/clap#1015 for tracking
it in clap, but let's clarify it ourselves for now by changing the
help text for `-h/--help`.
@epage epage added S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing and removed D: easy E-medium Call for participation: Experience needed to fix: Medium / intermediate E-easy Call for participation: Experience needed to fix: Easy / not much labels Dec 9, 2021
@epage epage removed this from the 3.1 milestone Dec 9, 2021
@epage epage added the C-enhancement Category: Raise on the bar on expectations label Dec 13, 2021
@AndreKR
Copy link

AndreKR commented Mar 22, 2022

Is it reasonable for clap to split up -h and --help into two arguments, so they appear on two lines in the help text?

Yes, they should absolutely be on separate lines if they do different things. The distinction between short and long help might make sense but putting -h, --help and expecting that users realize that they are different does not.

@epage
Copy link
Member

epage commented Apr 18, 2022

For those that only want one or the other, #3405 might be a way of forcing it by having HelpShort, HelpLong, and HelpAuto actions.

@epage
Copy link
Member

epage commented Aug 31, 2022

Thought it was interesting to see how some tools handle this

$ rg -h 
...
Use -h for short descriptions and --help for more details.
...
$ rg --help
...
Use -h for short descriptions and --help for more details.
...
$ bat -h
...
Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.
$ bat --help
...
Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.

What if we changed the help description for -h / --help

.help("Print this help message.  Use `--help` for more detail")
.long_help("Print this help message..  Use `-h` for a summary")

As kbknapp said earlier in this thread

True, but then again they might do the same thing

Since then

  • The derive has become the go-to way of configuring clap, making it more natural (or accidental) to provide long help
  • PossibleValue now has help which, if specified, will cause long help to be used

I'm thinking that putting these hints in the description for help would be good enough at this point in time to resolve this. cargo is a popular counter example that doesn't use long help. I wonder if it should make --help go to the man page like the help subcommand does though, like git.

@epage
Copy link
Member

epage commented Aug 31, 2022

We could also auto-detect if long help is used. Unsure if we want to pay that runtime price though.

epage added a commit to epage/clap that referenced this issue Aug 31, 2022
In reviewing CLIs for clap-rs#4132, I found some were providing helps on `-h`
vs `--help` and figured that could be built directly into clap.  I had
considered not making this hint automatic but I figured the overhead of
checking if long exists wouldn't be too bad.  The code exists (no binary
size increase) and just a simple iteration is probably not too slow
compared to everything else.

Fixes clap-rs#1015
epage added a commit to epage/clap that referenced this issue Aug 31, 2022
In reviewing CLIs for clap-rs#4132, I found some were providing helps on `-h`
vs `--help` and figured that could be built directly into clap.  I had
considered not making this hint automatic but I figured the overhead of
checking if long exists wouldn't be too bad.  The code exists (no binary
size increase) and just a simple iteration is probably not too slow
compared to everything else.

Fixes clap-rs#1015
@gasche
Copy link

gasche commented Oct 22, 2023

I hit this issue when using jj: I was reading doc using -h, it was missing the information I needed, and I wasted time because I did not think of using --help which I assumed was doing the exact same thing.

I am used to CLI interface conventions where the long and short names of an option do the same thing. It would never occur to me that -h and --help, if they both show help, would show different amount of help.

Personally I think that if two options do different things, they should have different short and long names. For example, one could have -h / --help on one hand and -sh / --short-help or -hs / --help-summary on the other hand.

@gasche
Copy link

gasche commented Oct 22, 2023

(Or maybe -h / --help for short help and --doc for "documentation" (long help).)

@epage
Copy link
Member

epage commented Oct 23, 2023

@gasche does jjs help output for --help say to use --help for more information?

I am used to CLI interface conventions where the long and short names of an option do the same thing. It would never occur to me that -h and --help, if they both show help, would show different amount of help.

I found it odd at first as well but it isn't unique to clap. git stash -h will show brief information and git stash --help will show the man page.

We are unlikely to remove support for it at this point due to compatibility within the applications that use it. We have made it configurable in 4.3.14, so applications can choose to switch to something else. We can explore changing the defaults though. However, the case for it would likely need to be strong due to the people relying on the current behavior.

The current convention is entrenched enough that we are unlikely to change i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants