Example #1
0
 /**
  * @param ICommand $command
  */
 public function render(ICommand $command)
 {
     $arguments = $command->getArguments();
     if (count($arguments) === 0) {
         return;
     }
     $table = new TableWidget($this->input, $this->output);
     $table->setTitle("<header>Arguments:</header>");
     foreach ($arguments as $argument) {
         $name = $argument->getName();
         $description = $argument->getDescription();
         if ($argument->isRequired()) {
             if ($argument->isMultiple()) {
                 $name = "\\<{$name}...>";
             } else {
                 $name = "\\<{$name}>";
             }
         } else {
             if ($argument->isMultiple()) {
                 $name = "\\<{$name}... ?>";
             } else {
                 $name = "\\<{$name} ?>";
             }
         }
         $table->addRow("<keyword>{$name}</keyword>", $description);
     }
     $this->output->writeLine();
     $table->render();
 }
 /**
  * @param ICommand $command
  */
 public function render(ICommand $command)
 {
     $description = $command->getDescription();
     if ($description) {
         $this->output->writeLine("<keyword>{$description}</keyword>");
     }
 }
Example #3
0
 /**
  * @param ICommand $command
  */
 public function render(ICommand $command)
 {
     $help = $command->getHelp();
     if ($help) {
         $this->output->writeLine();
         $this->output->writeLine('<header>Help:</header>');
         $this->output->writeLineIndented($help);
     }
 }
Example #4
0
    /**
     * @param ICommand $command
     */
    public function setup(ICommand $command)
    {
        $command->setName('help')->setDescription('Show help text')->setHelp(<<<EOT
To get help for a command run
 <keyword>help \\<command></keyword>

You can also use the --help option
 <keyword>\\<command> --help</keyword>
EOT
);
        $command->argument(ArgumentType::SINGLE_OPTIONAL, 'command')->setDescription('Command to show help for');
    }
 /**
  * @param ICommand $command
  * @param array $groupedArgs
  * @param bool $strict
  *
  * @return array
  * @throws MissingArgumentValueException
  * @throws TooManyArgumentValuesException
  * @throws UnknownOptionException
  */
 public function matchCommand(ICommand $command, array $groupedArgs, $strict = true)
 {
     foreach ($command->getArguments() as $argument) {
         $groupedArgs = $this->matchArgument($argument, $groupedArgs, $strict);
     }
     $leftoverArgs = array_get($groupedArgs, 'arguments', []);
     if (is_array($leftoverArgs) && count($leftoverArgs) > 0 && $strict) {
         throw new TooManyArgumentValuesException(s('Too many arguments, remove: %s.', implode(', ', $leftoverArgs)));
     }
     $foundOptions = ['arguments', 'options'];
     foreach ($command->getOptions() as $option) {
         $groupedArgs = $this->matchOption($option, $groupedArgs, $strict);
         $foundOptions[] = $option->getNameOrAlias();
     }
     if ($strict) {
         foreach ($groupedArgs as $key => $arg) {
             if (!array_contains($foundOptions, $key)) {
                 throw new UnknownOptionException(s('Invalid option "%s".', $key));
             }
         }
     }
     return $groupedArgs;
 }
    /**
     * @param ICommand $command
     */
    public function setup(ICommand $command)
    {
        $command->setName('config:dump')->setDescription('Dump configuration');
        $command->argument(ArgumentType::SINGLE_OPTIONAL, 'search')->setDescription('Config node name to dump');
        $command->setHelp(<<<EOT
You can dump all config with
 <keyword>config:dump</keyword>

You can filter config by key
 <keyword>config:dump keyword</keyword>

This will match a config starting with "<yellow>keyword</yellow>"
 <keyword>config:dump keyword*</keyword>

This will match a config ending with "<yellow>keyword</yellow>"
 <keyword>config:dump *keyword</keyword>

This will match everything that has "<yellow>keyword</yellow>" somewhere in the string
 <keyword>config:dump *keyword*</keyword>

EOT
);
    }
Example #7
0
 /**
  * @param ICommand $command
  */
 public function render(ICommand $command)
 {
     $options = $command->getOptions();
     if (count($options) === 0) {
         return;
     }
     $table = new TableWidget($this->input, $this->output);
     $table->setTitle("<header>Options:</header>");
     foreach ($options as $option) {
         $name = $option->getName();
         $alias = '   ';
         if ($option->getAlias()) {
             $alias = $option->getAlias();
             if ($option->isIncremental()) {
                 $alias = s('-:a|:a:a|:a:a:a', [':a' => substr($alias, 1)]);
             }
             $alias .= ',';
         }
         $table->addRow("<keyword>{$alias} {$name}</keyword>", $option->getDescription());
     }
     $this->output->writeLine();
     $table->render();
 }
Example #8
0
 /**
  * @param ICommand $command
  */
 public function render(ICommand $command)
 {
     $name = $command->getName();
     $usage = "{$name} ";
     if (count($command->getArguments())) {
         $usage .= $this->getArgumentsUsage($command->getArguments());
     }
     if (count($command->getOptions())) {
         $usage .= ' ' . $this->getOptionsUsage($command->getOptions());
     }
     $usage = trim($usage);
     $this->output->writeLine();
     $this->output->writeLine("<header>Usage:</header>");
     $this->output->writeLineIndented("{$usage}");
 }
Example #9
0
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setGlobal(true)->setHidden(true);
     $command->option(OptionType::SINGLE_OPTIONAL, '--format', '-f')->setDescription('Output format: normal, plain, raw');
 }
Example #10
0
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setGlobal(true)->setHidden(true);
     $command->option(OptionType::INCREMENTAL, '--verbosity', '-v')->setDescription('Output verbosity: 0 = normal, 1 = verbose, 2 = debug, 3 = silent');
 }
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setGlobal(true)->setHidden(true);
     $command->option(OptionType::BOOLEAN, '--no-interaction', '-n')->setDescription('Disable interactions like questions, prompts, etc');
 }
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setGlobal(true)->setHidden(true);
     $command->option(OptionType::SINGLE_OPTIONAL, '--env')->setDescription('Set application environment');
 }
Example #13
0
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setGlobal(true)->setHidden(true);
     $command->option(OptionType::BOOLEAN, '--passthrough')->setDescription('Do not catch any errors or exceptions');
 }
Example #14
0
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setName('list')->setDescription('List all available commands');
 }
Example #15
0
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setGlobal(true);
     $command->argument(ArgumentType::MULTIPLE_OPTIONAL, 'args');
     $command->option(OptionType::BOOLEAN, '--help', '-h')->setDescription('Show help text');
 }
Example #16
0
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setGlobal(true)->setHidden(true);
     $command->option(OptionType::BOOLEAN, '--silent', '-s')->setDescription('Disable input and output');
 }
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setName('router:dump')->setDescription('Dump routes');
 }
Example #18
0
 /**
  * @param ICommand $command
  */
 public function setup(ICommand $command)
 {
     $command->setGlobal(true);
     $command->option(OptionType::BOOLEAN, '--version', '-V')->setDescription('Show application version');
 }