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

Show subcommand about on same line, even in --help #4897

Closed
2 tasks done
Centri3 opened this issue May 9, 2023 · 1 comment · Fixed by #4902
Closed
2 tasks done

Show subcommand about on same line, even in --help #4897

Centri3 opened this issue May 9, 2023 · 1 comment · Fixed by #4902
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@Centri3
Copy link

Centri3 commented May 9, 2023

Please complete the following tasks

Clap Version

master

Describe your use case

It's easier to read, of course when long_about (not just the summary) is used, putting it on the same line is less than desirable, but this always shows the summary anyway.

Example:

Usage: a <X> <COMMAND>

Commands:
  lol   This, however - since it's only showing the summary, it may be easier to digest if it's on the same line, or just cleaner (ok, that isn't a summary...)
  help  Print this message or the help of the given subcommand(s)

Arguments:
  <X>
          Really short summary
          
          Very long and descriptive, perhaps overly descriptive explanation of what
          this code does and utterly every little detail of it...
          
          Since this is NOT just the summary, it's ok to put this on multiple lines.

Options:
  -h, --help
          Print help (see a summary with '-h')

Describe the solution you'd like

Currently, line 898 in help_template.rs (or, somewhere in write_subcommands):

self.write_subcommand(sc_str, sc, next_line_help, longest);

Switch this to:

self.write_subcommand(sc_str, sc, false, longest);

This will cause clap to always show subcommands on the same line.

Alas, This is not future proof.

Alternatives, if applicable

#1334, or just no changes. It's fine currently.

Additional Context

Since it only ever shows about and not long_about for subcommands in particular, it makes sense for it to (by default) show it on the same line, since it's the summary. -h does this, and so does --help too - unless long_about is provided on anything.

if next_line_help(true) is passed, then it should preserve the current behavior of course.

@Centri3 Centri3 added the C-enhancement Category: Raise on the bar on expectations label May 9, 2023
epage added a commit to epage/clap that referenced this issue May 12, 2023
Subcommands don't switch their behavior on `--help`, so let's not switch
to next-line-help based on `--help`.

Fixes clap-rs#4897
@epage
Copy link
Member

epage commented May 12, 2023

Created #4902

epage added a commit to epage/clap that referenced this issue May 19, 2023
Subcommands don't switch their behavior on `--help`, so let's not switch
to next-line-help based on `--help`.

Fixes clap-rs#4897
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants