-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force the display of a command's help text from ExecuteAsync? #48
Comments
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: 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 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 [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 :)
The text was updated successfully, but these errors were encountered: