int ProcessArgument(int idx, string argument, string[] args, int argsLen) { int argnameIdx = 1; bool haveMoreDashes = false, badArg = false; int argumentLen = argument.Length; if (argumentLen < 2) { badArg = true; } haveMoreDashes = !badArg && (argument [1] == '-'); if (argumentLen == 2 && haveMoreDashes) { badArg = true; } if (badArg) { Console.Error.WriteLine("Invalid argument: {0}", argument); Environment.Exit(1); } if (haveMoreDashes) { argnameIdx++; } int paramPos = argument.IndexOfAny(paramStartChars, argnameIdx); bool haveParam = true; if (paramPos == -1) { haveParam = false; paramPos = argumentLen; } string argName = argument.Substring(argnameIdx, paramPos - argnameIdx); string argParam = haveParam ? argument.Substring(paramPos + 1) : null; int ret = 0; if (!haveParam && haveMoreDashes) { idx++; if (idx < argsLen) { argParam = args [idx]; ret++; haveParam = true; } } switch (argName) { case "?": case "h": case "help": Usage(); break; case "v": case "version": ShowVersion(); break; case "t": case "target": if (!haveParam) { RequiredParameterMissing(argName); } try { Target = Helpers.ConvertEnum <FeatureTarget> (argParam, "target"); } catch (Exception ex) { OptionParameterError(argName, ex.Message); } break; default: unknown_arguments.Add(argName, argParam); break; } return(ret); }
public FeatureBlock (XPathNavigator node, FeatureTarget target) { this.name = Helpers.GetRequiredNonEmptyAttribute (node, "name"); this.target = target; }