-
Notifications
You must be signed in to change notification settings - Fork 403
add global options, make -h a proper option #771
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
add global options, make -h a proper option #771
Conversation
public void There_are_no_parse_errors_when_help_is_invoked_on_root_command() | ||
{ | ||
var parser = new CommandLineBuilder() | ||
.UseDefaults() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the assumption that .UseDefaults()
includes help. Though probably reasonable, I think it might be more clear to only test with .UseHelp()
}; | ||
|
||
var parser = new CommandLineBuilder(command) | ||
.UseDefaults() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here. Consider use .UseHelp()
rather than .UseDefaults()
{ | ||
if (symbol is Option option) | ||
if (child is Command childCommand) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider .OfType<Command>()
on the foreach to reduce nesting.
A consequence of this change is that it also adds help output to Usage:
myapp [options]
Options:
--version Show version information
-h, /h, -?, /?, --help Show help and usage information
-f Do some other stuff |
Any thoughts on changing the output on help to not display items that only differ by prefix? I would assume that would then make the output look something like:
|
I like that. It does leave aside the question of Windows-style option prefixes (#351). |
Let's do it! |
d46ba83
to
c9d2900
Compare
@Keboo Looks what you've made me do... |
@jonsequitur nice I like it |
c9d2900
to
a325d88
Compare
This reimplements help as a proper
Option
, which fixes #691. In order for the help option to be a single instance, looked up usingFindResultFor
after parsing, I also added support for global options (#587).This should also fix #766, the root cause of which is #691.
This will also fix #506.