/// <summary> /// Makes the specified name a valid command line argument. Command line /// arguments are assumed to be in the format /<name>:<value>. /// </summary> /// <param name="name">The name of the command line argument.</param> /// <param name="allowNull">If true no value for the specified name is necessary.</param> /// <param name="addAcronym">Add another valid argument of the acronym of the specified name</param> public static void AddValidArgument(string name, bool allowNull, bool addAcronym = false, string description = null, string valueExample = null) { ValidArgumentInfo.Add(new ArgumentInfo(name, allowNull, description, valueExample)); if (addAcronym) { ValidArgumentInfo.Add(new ArgumentInfo(name.CaseAcronym().ToLowerInvariant(), allowNull, $"{description}; same as {name}", valueExample)); } }
protected static void ParseArgs(string[] args) { Arguments = new ParsedArguments(args, ValidArgumentInfo.ToArray()); if (Arguments.Status == ArgumentParseStatus.Error || Arguments.Status == ArgumentParseStatus.Invalid) { ArgsParsedError?.Invoke(Arguments); } else if (Arguments.Status == ArgumentParseStatus.Success) { ArgsParsed?.Invoke(Arguments); } }
protected static void ParseArgs(string[] args) { Arguments = new ParsedArguments(args, ValidArgumentInfo.ToArray()); StackTrace = Arguments.Contains("stacktrace"); if (Arguments.Status == ArgumentParseStatus.Error || Arguments.Status == ArgumentParseStatus.Invalid) { if (ArgsParsedError != null) { ArgsParsedError(Arguments); } } else if (Arguments.Status == ArgumentParseStatus.Success) { if (ArgsParsed != null) { ArgsParsed(Arguments); } } }
/// <summary> /// Makes the specified name a valid command line argument. Command line /// arguments are assumed to be in the format /<name>:<value>. /// </summary> /// <param name="name">The name of the command line argument.</param> /// <param name="allowNull">If true no value for the specified name is necessary.</param> public static void AddValidArgument(string name, bool allowNull) { ValidArgumentInfo.Add(new ArgumentInfo(name, allowNull)); }