예제 #1
0
        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);
        }
예제 #2
0
        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();
        }
예제 #3
0
        private static string GetParameterSyntax(Argument parameter)
        {
            var sb = new StringBuilder();

            sb.Append(parameter.GetDisplayName());
            if (parameter.IsList)
                sb.Append(@"...");

            return sb.ToString();
        }
예제 #4
0
        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();
        }
예제 #5
0
 public void Add(Argument argument) => AddArgument(argument);
예제 #6
0
 public void AddArgument(Argument argument) => AddArgumentInner(argument);