clap-rs / clap

A full featured, fast Command Line Argument Parser for Rust
docs.rs/clap
Apache License 2.0
14.13k stars 1.03k forks source link

Make visible_alias print in a way that fits convention #5459

Open lolbinarycat opened 5 months ago

lolbinarycat commented 5 months ago

Please complete the following tasks

Clap Version

4.5.4

Describe your use case

print aliases in an easily understood way

Describe the solution you'd like

currently, aliases are printed at the end of the flag's description. i believe it would be much more natural to print them as -f, --flag, --alias description

Alternatives, if applicable

No response

Additional Context

No response

epage commented 5 months ago

Could you go into more detail on this as this is meant to be the jumping off point in the conversation.

For example

I assume you are somewhat connected with @tertsdiepraam who opened #5454. In that, concerns raised on the proposed output include

tertsdiepraam commented 5 months ago

Nope, I don't know @lolbinarycat. But we could use this issue as it seems to he about the same thing. Thanks for the mention and I'll follow this issue.

lolbinarycat commented 5 months ago

What prior art have you seen for this?

essentially every program that has aliases either prints them together, or prints them entirely separately, with the alias having a description like "alias for --some-other-flag"

for an example of the former see gnu tar (literally the first command i tried when you asked for an example)

epage commented 5 months ago

I had tried three or so commands and couldn't find examples of aliases.

Its also good to get from a variety of design spaces to explore multiple options. If you could find more prior art, that would be helpful.

Relevant parts from tar --help

Sometimes they use next line help

  -w, --interactive, --confirmation
                             ask for confirmation for every action

Sometimes they affect alignment

  -A, --catenate, --concatenate   append tar files to an archive
  -c, --create               create a new archive
      --delete               delete from the archive (not on mag tapes!)
  -d, --diff, --compare      find differences between archive and file system
  -r, --append               append files to the end of an archive
      --test-label           test the archive volume label and exit
  -t, --list                 list the contents of an archive
  -u, --update               only append files newer than copy in archive
  -x, --extract, --get       extract files from an archive

When they take a value, they don't list the value for the short but they do for each long

  -F, --info-script=NAME, --new-volume-script=NAME
                             run script at end of each tape (implies -M)
Dyredhead commented 2 months ago

I would love for this to be implemented, such that it is easier to see from the --help dialouge. eza also does this, albiet only in their manpage:


       --color=WHEN, --colour=WHEN
              When to use terminal colours (using ANSI escape code to colorize the output).

       Valid settings are ‘always', ‘automatic' (or ‘auto' for short), and ‘never'.  The default value is ‘automatic'.

       The  default behavior (‘automatic' or ‘auto') is to colorize the output only when the standard output is connected to a real terminal.  If the output of eza is redirected to a file
       or piped into another program, terminal colors will not be used.  Setting this option to ‘always' causes eza to always output terminal color, while ‘never' disables the use of ter‐
       minal color.

       Manually setting this option overrides NO_COLOR environment.

       --color-scale, --colour-scale
              highlight levels of field distinctly.  Use comma(,) separated list of all, age, size

       --color-scale-mode, --colour-scale-mode
              Use gradient or fixed colors in --color-scale.

       Valid options are fixed or gradient.  The default value is gradient.

In terms of ordering I think:

  1. short
  2. short aliases
  3. long
  4. long aliases

Would make the most sense.