public CommandWithOptions(IEnumerable<string> args)
 {
     var queue = new Queue<string>(args);
     if (!Command.TryParse(queue, out _command))
     {
         _command = new Help { Options = this };
         return;
     }
     _command.Options = this;
     IEnumerable<Option> commandLineOptions;
     while (Option.TryParse(queue, out commandLineOptions))
     {
         _options.AddRange(commandLineOptions);
     }
     _arguments.AddRange(queue);
 }
Example #2
0
 static public bool TryParse(Queue<string> queue, out Command command)
 {
     command = null;
     if (queue.Count == 0)
     {
         using (new OutputWriterErrorHighlight())
         {
             OutputWriter.WriteLine(
                 OutputVerbosity.Quiet,
                 @"You must specify a command.");
         }
         OutputWriter.WriteLine();
         return false;
     }
     string commandName = queue.Dequeue();
     return TryParse(commandName, out command);
 }
Example #3
0
 static protected bool TryParse(string commandName, out Command command)
 {
     command = null;
     if (!KnownCommands.ContainsKey(commandName))
     {
         using (new OutputWriterErrorHighlight())
         {
             OutputWriter.WriteLine(
                 OutputVerbosity.Quiet,
                 @"Unkown command '{0}' specified.",
                 commandName);
         }
         OutputWriter.WriteLine();
         return false;
     }
     command = (Command)Activator.CreateInstance(KnownCommands[commandName]);
     return true;
 }
 public CommandWithOptions(Command command)
 {
     _command = command;
     _command.Options = this;
 }