예제 #1
0
 /// <summary>
 /// Creates a new command with key matching specific type and non-keypair
 /// </summary>
 /// <param name="type">matching types</param>
 /// <returns></returns>
 public static CommandArgRule KeyTypeAs(CommandArgItemType type)
 {
     if (type == CommandArgItemType.None)
     {
         throw new ArgumentException("invalid rule none type match");
     }
     return(new CommandArgRule((arg) => !arg.IsKeyPair && (type & arg.Type) != 0));
 }
예제 #2
0
 /// <summary>
 /// Creates a command argument key value
 /// </summary>
 /// <param name="key">key value</param>
 public CommandArgValue(string key)
 {
     // task
     // -task			an option
     // --task
     // /f		/src	a directive
     // /fG8
     //
     Type = GetType(Key = key);
 }
예제 #3
0
 /// <summary>
 /// Creates a new command (key, pair) as a key equals an string and an specific value-type
 /// </summary>
 /// <param name="key">key string</param>
 /// <param name="valueType">value-type</param>
 /// <returns></returns>
 public static CommandArgRule KeyPairAs(string key, CommandArgItemType valueType)
 {
     if (key == null || valueType == CommandArgItemType.None)
     {
         throw new ArgumentException("invalid rule key and/or value type");
     }
     return(new CommandArgRule((arg) =>
                               arg.IsKeyPair &&
                               arg.Key == key.Trim() &&
                               (arg as CommandArgKeypair).ValueType == valueType
                               ));
 }
예제 #4
0
        /// <summary>
        /// Creates a command argument key value pair
        /// </summary>
        /// <param name="key">key value</param>
        /// <param name="value">value of the key</param>
        public CommandArgKeypair(string key, string value)
            : base(key)
        {
            //value can not be an Option nor a Directive
            //  Identifier | Integer | String
            // /f:34
            // --option:"dddd"
            // /f:for

            if ((ValueType = GetType(Value = value)) == CommandArgItemType.Option ||
                ValueType == CommandArgItemType.Directive)
            {
                throw new ArgumentException($"invalid command argument key pair: {this}");
            }
        }