public IEnumerable<ICommandLineElement> Parse(string commandLine) { var parser = new StringCommandLineParser(); Result<string, ICommandLineElement> result = parser.All(commandLine); while (result != null) { yield return result.Value; result = parser.All(result.Rest); } }
/// <summary> /// Parses the command line /// </summary> /// <param name="commandLine"> The command line to parse </param> /// <returns> The command line elements that were found </returns> static IEnumerable <ICommandLineElement> Parse(string commandLine) { Result <string, ICommandLineElement> result = Parser.All(commandLine); while (result != null) { yield return(result.Value); string rest = result.Rest; result = Parser.All(rest); } }
/// <summary> /// Parses the command line /// </summary> /// <param name="commandLine"> The command line to parse </param> /// <returns> The command line elements that were found </returns> private static string ParseCommandLine(string commandLine) { var parser = new StringCommandLineParser(); var result = parser.All(commandLine); while (result != null) { var element = result.Value as DefinitionElement; if (element != null && element.Key.ToLowerInvariant() == "task") { return(element.Value.ToLowerInvariant().Trim()); } result = parser.All(result.Rest); } return(null); }
/// <summary> /// Parses the command line /// </summary> /// <param name="commandLine"> The command line to parse </param> /// <returns> The command line elements that were found </returns> private static Service?ParseCommandLine(string commandLine) { var parser = new StringCommandLineParser(); var result = parser.All(commandLine); while (result != null) { var element = result.Value as DefinitionElement; if (element != null && element.Key.ToLowerInvariant() == "instance") { return((Service)Enum.Parse(typeof(Service), element.Value, true)); } result = parser.All(result.Rest); } return(null); }