Exemple #1
0
        private static CmdLine ParseSpacedCmdLine(IList <string> args)
        {
            var cmdLine = new CmdLine();

            for (var i = 0; i < args.Count; i++)
            {
                //Add first as param
                if (args[i].IndexOf('=') != -1)
                {
                    ParseSpaced(args[i], cmdLine);
                }
                else
                {
                    var param = new CmdLineParam {
                        Name = args[i], ShortName = args[i], JoinType = CmdLineJoinType.Space
                    };
                    if (i + 1 < args.Count && !string.IsNullOrEmpty(args[i + 1]))
                    {
                        param.Value = args[i + 1].Trim('"');
                        i++;
                    }
                    else
                    {
                        param.Value    = true;
                        param.JoinType = CmdLineJoinType.OnlyValues;
                    }
                    cmdLine.Add(param);
                }
            }
            return(cmdLine);
        }
Exemple #2
0
 private static void ParseSpaced(string paramEq, CmdLine cmdLine)
 {
     if (!string.IsNullOrEmpty(paramEq))
     {
         var values = paramEq.Split('=');
         var param  = new CmdLineParam {
             Name = values[0], ShortName = values[0], JoinType = CmdLineJoinType.Equals
         };
         if (values.Length == 2 && !string.IsNullOrEmpty(values[1]))
         {
             param.Value = values[1].Trim('"');
         }
         else
         {
             param.Value    = true;
             param.JoinType = CmdLineJoinType.OnlyValues;
         }
         cmdLine.Add(param);
     }
 }
Exemple #3
0
 public CmdLine Add(CmdLineParam param)
 {
     _parameters.Add(param);
     return(this);
 }