Пример #1
0
        public void Execute(string[] input)
        {
            var commandName    = "";
            var argumentValues = new Argument[0];

            if (input != null)
            {
                commandName = input.FirstOrDefault();

                var args = string.Join(
                    separator: " ",
                    values: input
                    .Skip(1)
                    .Select(x =>
                {
                    if (x.StartsWith("-"))
                    {
                        return(x);
                    }

                    return(string.Format("\"{0}\"", x));
                })
                    );

                argumentValues = _commandLineParser
                                 .ParseArguments(args)
                                 .ToArray();
            }

            Execute(commandName, argumentValues);
        }
Пример #2
0
 /// <summary>
 /// Parses a <see cref="System.String"/> array of command line arguments,
 /// setting values read in <paramref name="options"/> parameter instance.
 /// </summary>
 /// <param name="args">A <see cref="System.String"/> array of command line arguments.</param>
 /// <param name="options">An instance to receive values.
 /// Parsing rules are defined using <see cref="CommandLine.BaseOptionAttribute"/> derived types.</param>
 /// <returns>True if parsing process succeed.</returns>
 /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="args"/> is null.</exception>
 /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="options"/> is null.</exception>
 public static bool ParseArguments(string[] args, object options)
 {
     return(parser.ParseArguments(args, options));
 }