I defined the parameters as follows:
public class ArgumentsHeader
{
[VerbOption("configure", HelpText = "Sets configuration on server.")]
public ServerConfigurationArguments ServerConfigurationArguments { get; set; }
[HelpVerbOption]
public string GetUsage(string s)
{
return HelpText.AutoBuild(this, s);
}
}
public class ServerConfigurationArguments : ArgumentsBase
{
[Option('f', "filename", HelpText = "Path to JSON configuration file", DefaultValue = "config.json", Required = true)]
public string PathToConfig { get; set; }
}
Then parse them as follows:
string invokedVerb = null;
object invokedVerbInstance = null;
var parser = new Parser(x =>
{
x.MutuallyExclusive = true;
});
var options = new ArgumentsHeader();
if (!parser.ParseArguments(args, options,
(verb, subOptions) =>
{
invokedVerb = verb;
invokedVerbInstance = subOptions;
}))
{
Exit(ExitStatus.InvalidArguments);
}
But if I try to run exe using "help configure", it just prints all the help, and in the GetUsage (string) method, only the "help" command appears in the debugger.
Is this a mistake or what?
source
share