function drush_get_global_options

8.0.x drush.inc drush_get_global_options($brief = FALSE)
6.x drush.inc drush_get_global_options($brief = FALSE)
7.x drush.inc drush_get_global_options($brief = FALSE)
4.x drush.inc drush_get_global_options($brief = FALSE)
5.x drush.inc drush_get_global_options($brief = FALSE)
master drush.inc drush_get_global_options($brief = FALSE)

Get the available global options. Used by help command. Command files may modify this list using hook_drush_help_alter().

Parameters

boolean $brief: Return a reduced set of important options. Used by help command.

Return value

An associative array containing the option definition as the key, and a descriptive array for each of the available options. The array elements for each item are:

  • short-form: The shortcut form for specifying the key on the commandline.
  • propagate: backend invoke will use drush_get_option to propagate this option, when set, to any other Drush command that is called.
  • context: The drush context where the value of this item is cached. Used by backend invoke to propagate values set in code.
  • never-post: If TRUE, backend invoke will never POST this item's value on STDIN; it will always be sent as a commandline option.
  • never-propagate: If TRUE, backend invoke will never pass this item on to the subcommand being executed.
  • local-context-only: Backend invoke will only pass this value on for local calls.
  • merge: For options such as $options['shell-aliases'] that consist of an array of items, make a merged array that contains all of the values specified for all of the contexts (config files) where the option is defined. The value is stored in the specified 'context', or in a context named after the option itself if the context flag is not specified. IMPORTANT: When the merge flag is used, the option value must be obtained via drush_get_context('option') rather than drush_get_option('option').
  • merge-pathlist: For options such as --include and --config, make a merged list of options from all contexts; works like the 'merge' flag, but also handles string values separated by the PATH_SEPARATOR.
  • merge-associative: Like 'merge-pathlist', but key values are preserved.
  • propagate-cli-value: Used to tell backend invoke to include the value for this item as specified on the cli. This can either override 'context' (e.g., propagate --include from cli value instead of DRUSH_INCLUDE context), or for an independent global setting (e.g. --user)
  • description: The help text for this item. displayed by `drush help`.
12 calls to drush_get_global_options()
DrushCommand::buildDefinitionFromConfig in lib/Drush/Psysh/DrushCommand.php
Build a command definition from Drush command configuration array.
drush_command_set_command_specific in includes/command.inc
drush_complete_rebuild in includes/complete.inc
Rebuild and cache completions for everything except command arguments.
drush_expand_short_form_options in includes/context.inc
For all global options with a short form, convert all options in the option array that use the short form into the long form.
drush_global_options_command in commands/core/help.drush.inc
Build a fake command for the purposes of showing examples and options.

... See full list

File

includes/drush.inc, line 271
The drush API implementation and helpers.

Code

function drush_get_global_options($brief = FALSE) {
  $options['root'] = array(
    'short-form' => 'r',
    'short-has-arg' => TRUE,
    'never-post' => TRUE,
    'description' => "Drupal root directory to use (default: current directory).",
    'example-value' => 'path',
  );
  $options['uri'] = array(
    'short-form' => 'l',
    'short-has-arg' => TRUE,
    'never-post' => TRUE,
    'description' => 'URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).',
    'example-value' => 'http://example.com:8888',
  );
  $options['verbose'] = array(
    'short-form' => 'v',
    'context' => 'DRUSH_VERBOSE',
    'description' => 'Display extra information about the command.',
  );
  $options['debug'] = array(
    'short-form' => 'd',
    'context' => 'DRUSH_DEBUG',
    'description' => 'Display even more information, including internal messages.',
  );
  $options['yes'] = array(
    'short-form' => 'y',
    'context' => 'DRUSH_AFFIRMATIVE',
    'description' => "Assume 'yes' as answer to all prompts.",
  );
  $options['no'] = array(
    'short-form' => 'n',
    'context' => 'DRUSH_NEGATIVE',
    'description' => "Assume 'no' as answer to all prompts.",
  );
  $options['simulate'] = array(
    'short-form' => 's',
    'context' => 'DRUSH_SIMULATE',
    'never-propagate' => TRUE,
    'description' => "Simulate all relevant actions (don't actually change the system).",
  );
  $options['pipe'] = array(
    'short-form' => 'p',
    'hidden' => TRUE,
    'description' => "Emit a compact representation of the command for scripting.",
  );
  $options['help'] = array(
    'short-form' => 'h',
    'description' => "This help system.",
  );

  if (!$brief) {
    $options['version'] = array('description' => "Show drush version.");
    $options['php'] = array(
      'description' => "The absolute path to your PHP intepreter, if not 'php' in the path.",
      'example-value' => '/path/to/file',
      'never-propagate' => TRUE,
    );
    $options['interactive'] = array(
      'short-form' => 'ia',
      'description' => "Force interactive mode for commands run on multiple targets (e.g. `drush @site1,@site2 cc --ia`).",
      'never-propagate' => TRUE,
    );
    $options['tty'] = array(
      'hidden' => TRUE,
      'description' => "Force allocation of tty for remote commands",
      'never-propagate' => TRUE,
    );
    $options['quiet'] = array(
      'short-form' => 'q',
      'description' => 'Suppress non-error messages.',
    );
    $options['include'] = array(
      'short-form' => 'i',
      'short-has-arg' => TRUE,
      'context' => 'DRUSH_INCLUDE',
      'never-post' => TRUE,
      'propagate-cli-value' => TRUE,
      'merge-pathlist' => TRUE,
      'description' => "A list of additional directory paths to search for drush commands.",
      'example-value' => '/path/dir',
    );
    $options['exclude'] = array(
      'propagate-cli-value' => TRUE,
      'never-post' => TRUE,
      'merge-pathlist' => TRUE,
      'description' => "A list of files and directory paths to exclude from consideration when searching for drush commandfiles.",
      'example-value' => '/path/dir',
    );
    $options['config'] = array(
      'short-form' => 'c',
      'short-has-arg' => TRUE,
      'context' => 'DRUSH_CONFIG',
      'never-post' => TRUE,
      'propagate-cli-value' => TRUE,
      'merge-pathlist' => TRUE,
      'description' => "Specify an additional config file to load. See example.drushrc.php.",
      'example-value' => '/path/file',
    );
    $options['user'] = array(
      'short-form' => 'u',
      'short-has-arg' => TRUE,
      'propagate-cli-value' => TRUE,
      'description' => "Specify a Drupal user to login with. May be a name or a number.",
      'example-value' => 'name_or_number',
    );
    $options['backend'] = array(
      'short-form' => 'b',
      'never-propagate' => TRUE,
      'description' => "Hide all output and return structured data.",
    );
    $options['choice'] = array(
      'description' => "Provide an answer to a multiple-choice prompt.",
      'example-value' => 'number',
    );
    $options['variables'] = array(
      'description' => "Comma delimited list of name=value pairs. These values take precedence even over settings.php variable overrides.",
      'example-value' => 'foo=bar,baz=yaz',
    );
    $options['search-depth'] = array(
      'description' => "Control the depth that drush will search for alias files.",
      'example-value' => 'number',
    );
    $options['ignored-modules'] = array(
      'description' => "Exclude some modules from consideration when searching for drush command files.",
      'example-value' => 'token,views',
    );
    $options['no-label'] = array('description' => "Remove the site label that drush includes in multi-site command output (e.g. `drush @site1,@site2 status`).");
    $options['label-separator'] = array('description' => "Specify the separator to use in multi-site command output (e.g. `drush @sites pm-list --label-separator=',' --format=csv`).");
    $options['nocolor'] = array(
      'context' => 'DRUSH_NOCOLOR',
      'propagate-cli-value' => TRUE,
      'description' => "Suppress color highlighting on log messages.",
    );
    $options['show-passwords'] = array('description' => "Show database passwords in commands that display connection information.");
    $options['show-invoke'] = array('description' => "Show all function names which could have been called for the current command. See drush_invoke().");
    $options['watchdog'] = array(
      'description' => "Control logging of Drupal's watchdog() to drush log. Recognized values are 'log', 'print', 'disabled'. Defaults to log. 'print' shows calls to admin but does not add them to the log.",
      'example-value' => 'print',
    );
    $options['cache-default-class'] = array(
      'description' => "A cache backend class that implements CacheInterface. Defaults to JSONCache.",
      'example-value' => 'JSONCache',
    );
    $options['cache-class-<bin>'] = array(
      'description' => "A cache backend class that implements CacheInterface to use for a specific cache bin.",
      'example-value' => 'className',
    );
    $options['early'] = array('description' => "Include a file (with relative or full path) and call the drush_early_hook() function (where 'hook' is the filename). The function is called pre-bootstrap and offers an opportunity to alter the drush bootstrap environment or process (returning FALSE from the function will continue the bootstrap), or return output very rapidly (e.g. from caches). See includes/complete.inc for an example.");
    $options['alias-path'] = array(
      'context' => 'ALIAS_PATH',
      'local-context-only' => TRUE,
      'merge-pathlist' => TRUE,
      'propagate-cli-value' => TRUE,
      'description' => "Specifies the list of paths where drush will search for alias files.",
      'example-value' => '/path/alias1:/path/alias2',
    );
    $options['backup-location'] = array(
      'description' => "Specifies the directory where drush will store backups.",
      'example-value' => '/path/to/dir',
    );
    $options['confirm-rollback'] = array('description' => 'Wait for confirmation before doing a rollback when something goes wrong.');
    $options['complete-debug'] = array(
      'hidden' => TRUE,
      'description' => "Turn on debug mode forf completion code",
    );
    $options['php-options'] = array(
      'description' => "Options to pass to `php` when running drush.  Only effective when using the drush.launcher script.",
      'never-propagate' => TRUE,
      'example-value' => '-d error_reporting="E_ALL"',
    );
    $options['deferred-sanitization'] = array(
      'hidden' => TRUE,
      'description' => "Defer calculating the sanitization operations until after the database has been copied. This is done automatically if the source database is remote.",
    );
    $options['remote-host'] = array(
      'hidden' => TRUE,
      'description' => 'Remote site to execute drush command on. Managed by site alias.',
    );
    $options['remote-user'] = array(
      'hidden' => TRUE,
      'description' => 'User account to use with a remote drush command. Managed by site alias.',
    );
    $options['remote-os'] = array(
      'hidden' => TRUE,
      'description' => 'The operating system used on the remote host. Managed by site alias.',
    );
    $options['site-list'] = array(
      'hidden' => TRUE,
      'description' => 'List of sites to run commands on. Managed by site alias.',
    );
    $options['reserve-margin'] = array(
      'hidden' => TRUE,
      'description' => 'Remove columns from formatted opions. Managed by multi-site command handling.',
    );
    $options['strict'] = array(
      'propagate' => TRUE,
      'description' => 'Return an error on unrecognized options. --strict=0: Allow unrecognized options.  --strict=2: Also return an error on any "warning" log messages.  Optional.  Default is 1.',
    );
    $options['command-specific'] = array(
      'hidden' => TRUE,
      'merge-associative' => TRUE,
      'description' => 'Command-specific options.',
    );
    $options['site-aliases'] = array(
      'hidden' => TRUE,
      'merge-associative' => TRUE,
      'description' => 'List of site aliases.',
    );
    $options['shell-aliases'] = array(
      'hidden' => TRUE,
      'merge' => TRUE,
      'never-propagate' => TRUE,
      'description' => 'List of shell aliases.',
    );
    $options['path-aliases'] = array(
      'hidden' => TRUE,
      'never-propagate' => TRUE,
      'description' => 'Path aliases from site alias.',
    );
    $options['ssh-options'] = array(
      'never-propagate' => TRUE,
      'description' => 'A string of extra options that will be passed to the ssh command',
      'example-value' => '-p 100',
    );
    $options['editor'] = array(
      'never-propagate' => TRUE,
      'description' => 'A string of bash which launches user\'s preferred text editor. Defaults to ${VISUAL-${EDITOR-vi}}.',
      'example-value' => 'vi',
    );
    $options['bg'] = array(
      'never-propagate' => TRUE,
      'description' => 'Run editor in the background. Does not work with editors such as `vi` that run in the terminal. Supresses config-import at the end.',
    );
    $options['db-url'] = array(
      'hidden' => TRUE,
      'description' => 'A Drupal 6 style database URL. Used by various commands.',
      'example-value' => 'mysql://root:pass@127.0.0.1/db',
    );
    $options['drush-coverage'] = array(
      'hidden' => TRUE,
      'never-post' => TRUE,
      'propagate-cli-value' => TRUE,
      'description' => 'File to save code coverage data into.',
    );
    $options['redirect-port'] = array(
      'hidden' => TRUE,
      'never-propagate' => TRUE,
      'description' => 'Used by the user-login command to specify the redirect port on the local machine; it therefore would not do to pass this to the remote machines.',
    );
    $options['cache-clear'] = array(
      'propagate' => TRUE,
      'description' => 'If 0, Drush skips normal cache clearing; the caller should then clear if needed.',
      'example-value' => '0',
    );
    $options['local'] = array(
      'propagate' => TRUE,
      'description' => 'Don\'t look in global locations for commandfiles, config, and site aliases',
    );

    $command = array(
      'options' => $options,
      '#brief' => FALSE,
    ) + drush_command_defaults('global-options', 'global_options', __FILE__);
    drush_command_invoke_all_ref('drush_help_alter', $command);

    $options = $command['options'];
  }
  return $options;
}