-
Notifications
You must be signed in to change notification settings - Fork 115
Show global help text when other commands are present and no arguments were provided. #217
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
Conversation
|
In this case, wouldn't there be no way to call the root command? var app = ConsoleApp.Create();
app.Add("", () => Console.WriteLine("foo"));
app.Add("a", (int x, int y) => { });
app.Add("ab", (int x, int y) => { });
app.Add("a b c", (int x, int y) => { });
app.Run(args); |
|
@neuecc about:
The root command will be called if there are arguments/options specific to it in the input. But yes, if the user wants to trigger a no args root command this will not work as in your example. It would require the user to hack this in some form like: // Add "default" command
if (args.Length == 0) args = ["default"];or if he wants to hide this from help: app.Add("", ([Hidden] bool trigger) => Console.WriteLine("foo"));
if (args.Length == 0) args = ["--trigger"];The question is which convention is better to support by default, If you wanted to support both, It is possible to add a static toggle |
|
I have concerns about losing the ability to call no-args root commands directly. My proposal:
What do you think? |
Both of these are also current behavior. So scrap the PR for now? |
Currently, the behavior in this case shows the help for the root command, not the global help (the command list is not displayed). Also, in reality, I think the root command in applications built with multiple commands + a root command will have required parameters, so I believe most cases will follow your suggestion... |
You're right, I'll make the changes. |
|
I added This also simplifies the branch in |
|
OK, thanks! |
|
@neuecc Thanks for merging! by the way, I tried emailing you at [email protected] from your profile but I’m not sure it is still in use. Is there a better way to reach you privately? |
|
Oh, the email is alive. |
Previously, when a root command and other commands were registered, executing the CLI with no arguments would output only the root command's help text, omitting the other available commands.
This behavior was inconsistent with running
-h | --help, which correctly displayed the global help text including all command descriptions.This PR fixes this inconsistency to better align with common CLI semantics. Now, when the CLI is run with no arguments, it displays the global help text, assuming the user is requesting usage guidelines.
And it adds tests for this scenario.