Closed domn1995 closed 4 years ago
Hey, thanks a lot! Glad you're enjoying it.
It's currently not possible to trigger help manually, although I have an idea how to implement it.
To understand your scenario a bit better, is your code available on GitHub or somewhere else I could take a look at? Or maybe you can give me a more applied example which involves real command names, etc?
Here's a really simple example repo I created: https://github.com/domn1995/HelpTextExample
Current output
>app command1
>
>app command1 sub1
Doing work...
As you can see, the output of the first command is blank. I would like to show the help text there instead.
Desired output
>app command1
Usage
app command1 [command]
Options
-h|--help Shows help text.
Commands
sub1
You can run `app command1 [command] --help` to show help on a specific command.
>app command1 sub1
Doing work...
Essentially, since command1
doesn't actually do any work, it just "organizes" the command line structure, I would like to show its help text when no arguments are given to make it clear to the user that this command doesn't really do anything.
If this is a feature that you believe would benefit the project, I would love to submit a PR. Just point me in the right direction.
Cheers!
My first idea is to extend the CommandException
with an extra parameter ShowHelp
, which would get inspected by CliApplication
. Then you would be able to do:
[Command("docker container")]
public class ContainerCommand : ICommand
{
public ValueTask ExecuteAsync(IConsole consonle) =>
throw new CommandException("Please specify a command.", showHelp: true);
}
I like it. Do you want me to create a new issue for the feature and submit a PR?
Sure, go ahead.
First of all, I love project! Here's the use case I'm trying figure out:
I have a pretty nested CLI app where some commands don't actually do anything, but rather just help organize the app. Example:
In this example, command
sub1
doesn't do anything except organize the structure of the commands. As such, in theICommand.ExecuteAsync(IConsole)
implementation, I'm simply returningdefault
. When running the app in the following mannermyapp sub
, it simply executes then exits without doing anything. My intended behavior, however, is for it to print its help text instead.Is it possible to do this currently? Or is there a better way to implement this pattern?
Thanks, and again, I love the library!!! And I hope you enjoy the three coffees I bought you @Tyrrrz :)