public static Arg.ValidatorDelegate ValidateString(int min, int max) { Arg.ValidatorDelegate ret = (string arg) => { return(ValidateRange(arg.Length, min, max)); }; return(ret); }
public static Arg.ValidatorDelegate ValidateDouble(double min, double max) { Arg.ValidatorDelegate ret = (string arg) => { return(ValidateRange(arg, double.Parse, min, max)); }; return(ret); }
public static Arg.ValidatorDelegate ValidateInt(int min, int max) { Arg.ValidatorDelegate ret = (string arg) => { return(ValidateRange(arg, int.Parse, min, max)); }; return(ret); }
public static Arg.ValidatorDelegate ValidateString(string regex) { Arg.ValidatorDelegate ret = (string arg) => { Regex pattern = new Regex(regex); return(pattern.IsMatch(arg)); }; return(ret); }
public void Add(string name, char flag, string helpText, string defaultValue, Arg.Type type, Arg.ValidatorDelegate validator) { Add(name, flag, helpText, defaultValue, type, validator, new string[] { }, new string[] { }); }
public void Add(string name, char flag, string helpText, string defaultValue, Arg.Type type, Arg.ValidatorDelegate validator, string[] conflicts, string[] overrides) { if (reservedVariablesAreLocked) { if (name == "help") { throw new ParseException($"Argument name 'help' is reserved for the help text."); } else if (flag == 'h') { throw new ParseException($"Argument flag 'h' is reserved for the help text."); } else if (name == "version") { throw new ParseException($"Argument name 'version' is reserved for the program version."); } else if (flag == 'v') { throw new ParseException($"Argument flag 'v' is reserved for the program version."); } } optionalArgs.Add(new OptionalArg(name, flag, helpText, defaultValue, type, validator, conflicts, overrides)); }