internal static IArgumentArity Default(Type type, Argument argument, ISymbol parent) { if (typeof(IEnumerable).IsAssignableFrom(type) && type != typeof(string)) { return(parent is ICommand ? ZeroOrMore : OneOrMore); } if (type == typeof(bool)) { return(ZeroOrOne); } if (parent is ICommand && (argument.HasDefaultValue || type.IsNullable())) { return(ZeroOrOne); } return(ExactlyOne); }
private static string GetArgumentRowHeader(Argument argument) { var sb = new StringBuilder(); foreach (var displayName in argument.GetDisplayNames()) { if (sb.Length > 0) sb.Append(@", "); sb.Append(displayName); } if (argument.IsOption && !argument.IsFlag) sb.Append(@" <arg>"); if (argument.IsList) sb.Append(@"..."); return sb.ToString(); }
private static string GetParameterSyntax(Argument parameter) { var sb = new StringBuilder(); sb.Append(parameter.GetDisplayName()); if (parameter.IsList) sb.Append(@"..."); return sb.ToString(); }
private static string GetOptionSyntax(Argument option) { var sb = new StringBuilder(); sb.Append(@"["); sb.Append(option.GetDisplayName()); if (!option.IsFlag) sb.Append(@" <arg>"); if (option.IsList) sb.Append(@"..."); sb.Append(@"]"); return sb.ToString(); }
public void Add(Argument argument) => AddArgument(argument);
public void AddArgument(Argument argument) => AddArgumentInner(argument);