/// <summary> /// Initializes a new instance of the <see cref="Argument"/> class. /// </summary> /// <param name="humanReadableName"> /// The human-readable name of this argument. This name will appear in error messages or help pages, but will /// not be used during parsing. /// </param> /// <param name="shortNames"> /// The short names of the argument. /// </param> /// <param name="longNames"> /// The long names of the argument. /// </param> /// <param name="description"> /// The description of the argument. /// </param> /// <param name="operandCount"> /// Operand count limitations associated with this argument. /// </param> public Argument( string humanReadableName, IReadOnlyInvariantSet <string> shortNames, IReadOnlyInvariantSet <string> longNames, string description, CountBounds operandCount) { if (null == humanReadableName) { throw new ArgumentNullException(nameof(humanReadableName)); } if (null == shortNames) { throw new ArgumentNullException(nameof(shortNames)); } if (null == longNames) { throw new ArgumentNullException(nameof(longNames)); } if (null == description) { throw new ArgumentNullException(nameof(description)); } if (null == operandCount) { throw new ArgumentNullException(nameof(operandCount)); } foreach (string name in shortNames) { if (name.Length < 1) { throw new ArgumentException("Short name must be at least one character long."); } } foreach (string name in longNames) { if (name.Length < 1) { throw new ArgumentException("Long name must be at least one character long."); } } this.HumanReadableName = humanReadableName; this.ShortNames = shortNames; this.LongNames = longNames; this.Description = description; this.OperandCount = operandCount; }
public RuntimeArgument( string humanReadableName, IReadOnlyInvariantSet <string> shortNames, IReadOnlyInvariantSet <string> longNames, string description, CountBounds?operandCount = null) : base( humanReadableName, shortNames, longNames, description, operandCount ?? CountBounds.Single) { }
public MockReadOnlyInvariantSet(IReadOnlyInvariantSet <T> set) : this( set.Contains, () => set.Count, set.Equals, set.GetEnumerator, set.GetHashCode, set.IsProperSubsetOf, set.IsProperSupersetOf, set.IsSubsetOf, set.IsSupersetOf, set.Overlaps, set.SetEquals, set.ToString) { }
public ArgumentParser(ParseStyle style, IReadOnlyInvariantSet <Argument> arguments) { if (ArgumentParser.NotImplementedStyles.Contains(style)) { throw new NotImplementedException("Specified parsing style is not yet implemented."); } this.Arguments = arguments ?? throw new ArgumentNullException(nameof(arguments)); this.Style = style; this.parser = style switch { ParseStyle.DOS => DosParser.Singleton, ParseStyle.GNU => GnuParser.Singleton, ParseStyle.MSBuild => MsBuildParser.Singleton, ParseStyle.Posix => PosixParser.Singleton, ParseStyle.Unity => UnityParser.Singleton, ParseStyle.Windows => WindowsParser.Singleton, _ => throw new NotImplementedException("Unrecognized parse style.") }; this.parser.ThrowIfIllegal(arguments); }