function annotationcommand_adapter_add_hook_options

master annotationcommand_adapter_add_hook_options(&$command)

Modify a $command record, adding option definitions defined by any command hook.


array $command Drush command record to modify:

4 calls to annotationcommand_adapter_add_hook_options()
annotationcommand_adapter_process_command in includes/
This function is set as the $command['callback'] for commands that have been converted to annotated commands. When the DRUSH_SYMFONY environment variable is set, these will be called via Symfony's Application::run() method. Otherwise,…
drush_core_helpsingle in commands/core/
Command callback. Show help for a single command.
drush_dispatch in includes/
Given a command record, dispatch it as if it were the original command. Executes in the currently bootstrapped site using the current option contexts. Note that drush_dispatch will not bootstrap any further than the current command has already…
_drush_invoke_hooks in includes/
Invoke Drush API calls, including all hooks.


includes/, line 457


function annotationcommand_adapter_add_hook_options(&$command) {
  // Get options added by hooks.  We postpone doing this until the
  // last minute rather than doing it when processing commandfiles
  // so that we do not need to worry about what order we process the
  // commandfiles in -- we can load extensions late, and still have
  // the extension hook a core command, or have an early-loaded global
  // extension hook a late-loaded extension (e.g. attached to a module).
  $names = annotationcommand_adapter_command_names($command);
  $names[] = '*'; // we are missing annotations here; maybe we just don't support that? (TODO later, maybe)
  $factory = \Drush::commandFactory();
  $extraOptions = $factory->hookManager()->getHookOptions($names);
  foreach ($extraOptions as $commandinfo) {
    if (!isset($command['consolidation-option-defaults'])) {
      $command['consolidation-option-defaults'] = array();
    $command['consolidation-option-defaults'] += $commandinfo->options()->getValues();
    foreach ($commandinfo->options()->getValues() as $option => $default) {
      $description = $commandinfo->options()->getDescription($option);
      $command['options'][$option] =['description' $description];
      if (!empty($default)) {
        $command['options'][$option]['example-value'] = $default;
      if ($commandinfo->getAnnotation('hidden-option') == $option) {
        $command['options'][$option]['hidden'] = TRUE;
      $fn = 'annotationcommand_adapter_alter_option_description_' . $option;
      if (function_exists($fn)) {
        $command['options'][$option] = $fn($command['options'][$option], $commandinfo, $default);