drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.33k stars 1.08k forks source link

Options with bool(false) default value aren't a real flag #3779

Closed Sweetchuck closed 5 years ago

Sweetchuck commented 5 years ago

Describe the bug

Default value of an option which is defined like this $options = ['a' => FALSE] cannot be overridden from drush.yml.

I think all the options has to be overridable from drush.yml.

Here are the descriptions of the meanings of the default values: https://github.com/consolidation/annotated-command#option-default-values

To Reproduce

<?php

class FooCommands {
  /**
   * @command foo:bar
   */
  public function (
    $options = [
      'a' => FALSE,
    ]
  ) {
    var_dump($options['a']);
  }

}

Content of drush.yml

command:
  foo:
    bar:
      options:
       a: true

Run drush foo:bar

System Configuration

Q A
Drush version? Drush Commandline Tool 9.5.2
Drupal version? 8.6 but not relevant
PHP version? 7.2.11 but not relevant
OS? Linux

Use case

I would like run a Drush command like this drush site:install with the following drush.yml file:

command:
  site:
    install:
      options:
        existing-config: true

But the command.site.install.options.existing-config is totally ignored. Also the DRUSH_OPTIONS_EXISTING_CONFIG='true' drush site-install --existing-config command doesn't work. So I have to add it to CLI command, like this: drush site-install --existing-config.

List of commands

  1. \Drush\Commands\OptionsCommands::optionsetProcBuild
  2. \Drush\Commands\OptionsCommands::optionsetGetEditor
  3. \Drush\Commands\config\ConfigPullCommands::pull
  4. \Drush\Commands\core\CacheCommands::set
  5. \Drush\Commands\core\DrupalDirectoryCommands::drupalDirectory
  6. \Drush\Commands\core\DrupliconCommands::optionset
  7. \Drush\Commands\core\InitCommands::initializeDrush
  8. \Drush\Commands\core\RunserverCommands::runserver
  9. \Drush\Commands\core\SiteInstallCommands::install
  10. \Drush\Commands\core\UpdateDBCommands::updatedb
  11. \Drush\Commands\help\HelpCommands::help
  12. \Drush\Commands\help\ListCommands::helpList
  13. \Drush\Commands\sql\SqlCommands::conf
  14. \Drush\Commands\sql\SqlCommands::query
  15. \Drush\Commands\sql\SqlCommands::dump
  16. \Drush\Commands\sql\SqlSyncCommands::sqlsync
greg-1-anderson commented 5 years ago

Duplicate of https://github.com/drush-ops/drush/issues/2956