Open
Description
If I have a Command with a sub command all setup and working, and then I add an extra option, but you've made a typo (copy/paste).
var uploadPrefixOption = new Option<bool>("--uploadprefix", "prefix for the zip file") //Note the incorrect type should be string
{
IsRequired = false
};
uploadPrefixOption.SetDefaultValue("backup");
backupCommand.AddOption(uploadPrefixOption);
when
return await rootCommand.InvokeAsync(args);
actually runs, I get an error of :
Unhandled exception: System.ArgumentException: The SetHandler call for command 'backup' is missing an Argument or Option for the parameter at position 4. Did you mean to pass one of these?
Option<String> --name
at runtime.
The error is actually coming from the incorrect type being used for uploadPrefixOption.SetDefaultValue("backup")
.
But the message leads you to the --name
parameter, which is actually a bit of a redherring.
Would it be possible to throw the ArgumentException
(or similar) on the SetDefaultValue
because that's where the error actually is.