spectre.console
spectre.console copied to clipboard
First help screen for the CLI is misleading
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.
Yeah, you are right. This could be cleaner. I'd like to propose two things that hopefully help
- 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. - Have the ability to add a
help
command that would map to<COMMAND> -h
e.g.AproClientConsole help run
@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 therun
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 @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:
...
I second this, I think this is a good solution. The current implementation is misleading.
See my screenshot:
- My commands are 'path' and '.'
- I can add options after the command to configure the command
The help screen shows this:
- Options first --> Then Command
Proposed Solution:
USAGE:
AproClientConsole [OPTIONS]
AproClientConsole <COMMAND> [OPTIONS]
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
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));
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.