Beispiel #1
0
        public LinePrimitive <T> SharedOption <T>(string spec, string description, T defaultValue = default(T))
        {
            var op = new LinePrimitive <T>(true, spec, description, defaultValue);

            SharedOptions.Add(op);
            return(op);
        }
Beispiel #2
0
        /// <summary>
        /// Adds an option
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="spec"></param>
        /// <param name="description"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public LinePrimitive <T> Option <T>(string spec, string description, T defaultValue = default(T))
        {
            var op = new LinePrimitive <T>(true, spec, description, defaultValue);

            op.Command = this;
            _options.Add(op);
            return(op);
        }
Beispiel #3
0
        /// <summary>
        /// Adds a positional argument
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public LinePrimitive <T> Argument <T>(string name, string description, T defaultValue = default(T))
        {
            var arg = new LinePrimitive <T>(false, name, description, defaultValue);

            arg.Command = this;
            _arguments.Add(arg);
            return(arg);
        }
Beispiel #4
0
 internal void Add(LinePrimitive lp)
 {
     _options.Add(lp);
 }
Beispiel #5
0
 internal string GetOption(LinePrimitive option, bool isSwitch)
 {
     return(_args.GetOption(isSwitch, option.Name));
 }
Beispiel #6
0
        internal string GetArgument(LinePrimitive argument)
        {
            int index = _arguments.IndexOf(argument);

            return(_args.GetArgument(index));
        }
 public static LinePrimitive <T> Required <T>(this LinePrimitive <T> arg)
 {
     return(arg.AddValidator(new ValueRequiredValidator()));
 }
 public static LinePrimitive <T> FileExists <T>(this LinePrimitive <T> arg)
 {
     return(arg.AddValidator(new FileExistsValidator()));
 }