protected function DrushCommand::createInputOptionsFromConfig

8.0.x DrushCommand.php protected DrushCommand::createInputOptionsFromConfig(array $options_config)
master DrushCommand.php protected DrushCommand::createInputOptionsFromConfig(array $options_config)

Creates input definitions from command options.

Parameters

array $options_config:

Return value

\Symfony\Component\Console\Input\InputInterface[]

1 call to DrushCommand::createInputOptionsFromConfig()
DrushCommand::buildDefinitionFromConfig in lib/Drush/Psysh/DrushCommand.php
Build a command definition from Drush command configuration array.

File

lib/Drush/Psysh/DrushCommand.php, line 178
Contains \Drush\Psysh\DrushCommand.

Namespace

Drush\Psysh

Class

DrushCommand
Main Drush command.

Code

protected function createInputOptionsFromConfig(array $options_config) {
  $definitions =[];

  foreach ($options_config as $name => $option) {
    // Some commands will conflict.
    if (in_array($name, ['help' 'command'])) {
      continue;
    }

    if (!is_array($option)) {
      $option =['description' $option];
    }

    if (!empty($option['hidden'])) {
      continue;
    }

    // @todo: Figure out if there's a way to detect InputOption::VALUE_NONE
    // (i.e. flags) via the config array.
    if (isset($option['value']) && $option['value'] === 'required') {
      $input_type = InputOption::VALUE_REQUIRED;
    }
    else {
      $input_type = InputOption::VALUE_OPTIONAL;
    }

    $definitions[] = new InputOption($name, !empty($option['short-form']) ? $option['short-form'] : '', $input_type, $option['description']);
  }

  return $definitions;
}