Example #1
0
        public InputArgumentList ParseArgs(List <string> argArr,
                                           out int missingArgIndex,
                                           out int missingArgCount,
                                           int flagsToInclude = 0,
                                           int flagsToExclude = 0)
        {
            InputArgumentList args = new InputArgumentList(argArr);

            // FIXME: Handle '@' args (or at least error on them).

            missingArgIndex = missingArgCount = 0;
            int index = 0;
            int end   = argArr.Count;

            while (index < end)
            {
                // Ingore nullptrs, they are response file's EOL markers
                if (args.GetArgString(index) == null)
                {
                    ++index;
                    continue;
                }

                // Ignore empty arguments (other things may still take them as arguments).
                string str = args.GetArgString(index);

                if (string.IsNullOrEmpty(str))
                {
                    ++index;
                    continue;
                }

                int prev = index;

                Argument a = ParseOneArg(args,
                                         ref index,
                                         flagsToInclude,
                                         flagsToExclude);

                //Debug.Assert(index > Prev && "Parser failed to consume argument.");

                // Check for missing argument error.
                if (a == null)
                {
                    //Debug.Assert(index >= End && "Unexpected parser error.");
                    //Debug.Assert(index - Prev - 1 && "No missing arguments!");
                    missingArgIndex = prev;
                    missingArgCount = index - prev - 1;
                    break;
                }

                args.Append(a);
            }

            return(args);
        }
Example #2
0
 /// Construct a new derived arg list from \p BaseArgs.
 public DerivedArgumentList(InputArgumentList baseArgs)
 {
     _baseArgs = baseArgs;
 }