-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
subcommand help flags cause exception #86
Comments
I've run into Here is an example that fails in the same way, using attributes and options other than [Command("fake-git")]
[Subcommand("commit", typeof(CommitCommand))]
class Git
{
protected int OnExecute(CommandLineApplication app)
{
return 1;
}
[Option(Inherited = true)]
public string Message2 { get; set; }
}
[Command(Description = "Record changes to the repository")]
class CommitCommand
{
[Option("-m")]
public string Message { get; set; }
} Stack trace:
|
Indeed, we can probably provide a better error, or just choose the HelpOption nearest to the selected command. Marking as up-for-grabs if someone wants to contribute a fix. |
Ah, I was just following what I understood was the right way to do it via the builder interface. If there is a better/more specific way to use the builder interface, I'd love to take a look at it. |
@mxplusb the simplest fix here for you is to only have one call to app.Command("get", (getcmd) =>
{
getcmd.Description = "Gets a list of things.";
- getcmd.HelpOption();
getcmd.OnExecute(() =>
{
getcmd.ShowHelp(); |
Hello @natemcmaster, |
Thanks @handcraftedsource! Yes, this is a good place to start. |
When trying to use a help flag on a subcommand, I get an
Unhandled Exception: System.InvalidOperationException: Sequence contains more than one matching element
error.Example code:
Here are the steps I am taking to create this:
> dotnet publish --self-contained -r win10-x64
> .\bin\Debug\netcoreapp2.0\win10-x64\publish\updater.exe get
> .\bin\Debug\netcoreapp2.0\win10-x64\publish\updater.exe get --help
It throws this exception:
Here is my dotnet configuration:
I very well could be doing something wrong, too.
The text was updated successfully, but these errors were encountered: