spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
9.25k stars 478 forks source link

Command aliases do not show in the help display #662

Open dlandi opened 2 years ago

dlandi commented 2 years ago

Example: config.AddCommand("install-cloud") .WithAlias("cloud").WithAlias("cld"); //config.AddCommand("cloud"); //config.AddCommand("cld");

If you use config.AddCommand(), each command shows up in help display, but the WithAlias() option does not.


Please upvote :+1: this issue if you are interested in it.

nils-a commented 2 years ago

@dlandi thanks for reporting this. Do you have any idea on what the help display should look like, if aliases were reported?

dlandi commented 2 years ago

Sure. Given:

      config.AddCommand<InstallCloudCommand>("install-cloud")
      .WithDescription("Install Cloud API from Zip File")
      .WithAlias("cloud").WithAlias("cld");

      config.AddCommand<InitializeAccountCommand>("init-account")
      .WithDescription("Initialize Account DB from Powershell Script File")
       WithAlias("account").WithAlias("adb"); 

       config.AddCommand<InitializeCloudDb>("init-cloud-db")
      .WithDescription("Initialize Cloud Database from Powershell Script File")
      .WithAlias("cloud-db").WithAlias("cdb");

Output would be :

Command          Alias[es]      Description
-------------------------------------------------------------------------------
install-cloud          [cloud|cld]               Install Cloud API from Zip File
init-account          [account|adb]          Initialize Account DB from Powershell Script File
init-cloud-db        [cloud-db|cdb]        Initialize Cloud Database from Powershell Script File
nils-a commented 2 years ago

Since the commands' section does not have headers, this would look like:

COMMANDS:
    dog <AGE>           some-dog, a-dog        The dog command
    giraffe <LENGTH>                           The giraffe command
    horse               some-horse, a-horse    The horse command

or

COMMANDS:
    dog <AGE>           [some-dog|a-dog]        The dog command
    giraffe <LENGTH>                            The giraffe command
    horse               [some-horse|a-horse]    The horse command

I feel adding a cell "aliases" to the commands' section would take away too much space (which is sometimes very limited in CLI).

What about adding it to the description? Something like:

COMMANDS:
    dog <AGE>           The dog command
                        Aliases: some-dog, a-dog
    giraffe <LENGTH>    The giraffe command
    horse               The horse command
                        Aliases: some-hosre, a-horse

@patriksvensson, @phil-scott-78: Any ideas or opinions?

BatanGaming commented 1 year ago

Hi there. I'd like to do it. What do you think about this layout?

COMMANDS:
    build-something        [build|b]    Builds something 
    no-alias                            Some description 
    create                 [c]          Creates something
Psychlist1972 commented 8 months ago

What about adding it to the description? Something like:

COMMANDS:
    dog <AGE>           The dog command
                        Aliases: some-dog, a-dog
    giraffe <LENGTH>    The giraffe command
    horse               The horse command
                        Aliases: some-hosre, a-horse

@patriksvensson, @phil-scott-78: Any ideas or opinions?

Did anything happen with this? I like the approach of putting the aliases under the description, as that makes the best use of space, IMO.

Pete