After upgrading to latest version (3.0.20), parsing now ignores the default value if the argument isn't defined in the arguments list. It instead will use the default value for the type. e.g. 0 for an int or enum.
public enum OptionsFlag
{
O1, O2, O3
}
public class Options
{
[ValueArgument(typeof( OptionsFlag), 'f', "flag", DefaultValue = OptionsFlag.O3)]
public OptionsFlag Flag = OptionsFlag.O3;
public static Options ParseOptions(string[] args)
{
var options = new Options();
Debug.Assert(options.Flag == OptionsFlag.O3);
var parser = new CommandLineParser.CommandLineParser();
parser.ExtractArgumentAttributes(options);
parser.ParseCommandLine(args);
// This will fail when args is empty! it has been set to O1
Debug.Assert(options.Flag == OptionsFlag.O3);
return options;
}
}
After upgrading to latest version (3.0.20), parsing now ignores the default value if the argument isn't defined in the arguments list. It instead will use the default value for the type. e.g. 0 for an int or enum.