function drush_get_option

8.0.x context.inc drush_get_option($option, $default = NULL, $context = NULL)
6.x context.inc drush_get_option($option, $default = NULL, $context = NULL)
7.x context.inc drush_get_option($option, $default = NULL, $context = NULL)
3.x context.inc drush_get_option($option, $default = NULL, $context = NULL)
4.x context.inc drush_get_option($option, $default = NULL, $context = NULL)
5.x context.inc drush_get_option($option, $default = NULL, $context = NULL)
master context.inc drush_get_option($option, $default = NULL, $context = NULL)

Get the value for an option.

If the first argument is an array, then it checks whether one of the options exists and return the value of the first one found. Useful for allowing both -h and --host-name

Parameters

option: The name of the option to get

default: Optional. The value to return if the option has not been set

context: Optional. The context to check for the option. If this is set, only this context will be searched.

69 calls to drush_get_option()
drush_core_call_rsync in commands/core/rsync.core.inc
Make a direct call to rsync after the source and destination paths have been evaluated.
drush_core_cli in commands/core/core.drush.inc
drush_core_help in commands/core/core.drush.inc
This is called if no command or an unknown command is entered.
drush_core_php_script in commands/core/core.drush.inc
Command callback. Runs "naked" php scripts.
drush_core_pre_site_install in commands/core/site_install.drush.inc

... See full list

File

includes/context.inc, line 361
The Drush context API implementation.

Code

function drush_get_option($option, $default = NULL, $context = NULL) {
  $value = null;

  if ($context) {
    // We have a definite context to check for the presence of an option.
    $value = _drush_get_option($option, drush_get_context($context));
  }
  else {
    // We are not checking a specific context, so check them in a predefined order of precedence.
    $contexts = drush_context_names();

    foreach ($contexts as $context) {
      $value = _drush_get_option($option, drush_get_context($context));

      if ($value !== null) {
        return $value;
      }
    }
  }

  if ($value !== null) {
    return $value;
  }

  return $default;
}