spectre.console icon indicating copy to clipboard operation
spectre.console copied to clipboard

First help screen for the CLI is misleading

Open Goffen opened this issue 3 years ago • 4 comments

Information

  • OS: Windows
  • Version: 0.38.0
  • Terminal: Windows Terminal

Describe the bug If you just enter "TesstApp.exe" you get:

USAGE:
    AproClientConsole [OPTIONS] <COMMAND>

OPTIONS:
    -h, --help       Prints help information
    -v, --version    Prints version information
...<snip>

To Reproduce If you enter "TestApp.exe -h run" it does not display the help I wanted. But if I run "TestApp.exe run -h" the help is shown for the command - how could I have understood this from first screen?

Expected behavior If you enter "TestApp -h run " the help is displayed. Or change the description of first screen.

Goffen avatar Mar 16 '21 22:03 Goffen

Yeah, you are right. This could be cleaner. I'd like to propose two things that hopefully help

  1. change the usage to AproClientConsole <COMMAND> [OPTIONS]. - @patriksvensson, can you think of a reason these are written out in this order? Looks to me it's hard coded that way so should be easy enough to fix if we just want to swap them.
  2. Have the ability to add a help command that would map to <COMMAND> -h e.g. AproClientConsole help run

phil-scott-78 avatar Mar 16 '21 22:03 phil-scott-78

@phil-scott-78 @Goffen It really does what it says really, and it is by design.

USAGE:
    AproClientConsole [OPTIONS] <COMMAND>

--help is an auto-implemented option for all commands.

  • In the first case (TestApp.exe -h) you invoke the --help option at the root, which will show the root help.
  • If you write TestApp.exe run -h you're invoking help for the run command.

Suggestion #1:

Perhaps we could change the usage description to something like this to make this clearer.

USAGE:
    AproClientConsole [OPTIONS] [COMMAND]

Suggestion #2:

USAGE:
    AproClientConsole [OPTIONS] [COMMAND]

OPTIONS:
    -h, --help [COMMAND]       Prints help information for the current command
                               or a specific sub-command.

I'm not opposed to making --help an flag option so you can specify a specific command in the current level to get help for, so AppClientConsole --help run would mean the same as AppClientconsole run --help.

patriksvensson avatar Mar 17 '21 17:03 patriksvensson

@patriksvensson @phil-scott-78 Maybe it's my lack of understanding of [ and < that I misinterpret alot.

Another alternative could be to show two usages:

USAGE:
    AproClientConsole [OPTIONS]
    AproClientConsole <COMMAND> [OPTIONS]

First one is for the auto-implemented "-h" and "-v"? Other one is for all user-implemented commands.


For example az

Use `az --version` to display the current version.
Here are the base commands:
  ...

Goffen avatar Mar 17 '21 18:03 Goffen

I second this, I think this is a good solution. The current implementation is misleading.

See my screenshot: image

  • My commands are 'path' and '.'
  • I can add options after the command to configure the command

The help screen shows this:

image

  • Options first --> Then Command

Proposed Solution:

USAGE:
    AproClientConsole [OPTIONS]
    AproClientConsole <COMMAND> [OPTIONS]

jeffward01 avatar Oct 22 '21 19:10 jeffward01

Something does need to be changed here. I think either changing the order in the usage would help

USAGE:
    AproClientConsole [COMMAND] [OPTIONS]

or making either order work:

AppClientConsole --help run would mean the same as AppClientconsole run --help.

Initially I was following the usage pattern and trying to get help from my command I was testing by typing MytConsole --help run with the option first and not getting any output. I only found out that I need to type MyConsole run --help when I was searching github and found this issue

dgosbell avatar Oct 03 '22 00:10 dgosbell

As a work around, I have created a function that addresses this situation

    private static string[] FixArgs(string[] asEntered)  
    {  
        List<string> newArgs = new List<string>(asEntered);  
        if ((newArgs[0].ToUpperInvariant() == "--HELP") ||  
            (newArgs[0].ToUpperInvariant() == "-H"))  
        {  
            newArgs.RemoveAt(0);  
            newArgs.Add("--help");  
        }  
        return newArgs.ToArray();  
    }  

I changed this statement app.Run(args); to app.Run(FixArgs(args));

NJ-Brad avatar Oct 07 '22 16:10 NJ-Brad

Much has moved on regarding spectre.console CLI and help behaviour since this thread was first created, and since the latest comment was made. There are also no current plans to change the current implementation. Please raise a new issue, with a proposal for discussion, if you feel strongly enough about something specific.

FrankRay78 avatar Jan 07 '24 19:01 FrankRay78