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.

126 calls to drush_get_option()
core_cli_bashrc in commands/core/core.drush.inc
drush_archive_dump in commands/core/archive.drush.inc
Command callback. Generate site archive file.
drush_archive_restore in commands/core/archive.drush.inc
Command callback. Restore web site(s) from a site archive file.
drush_cache_get in commands/core/cache.drush.inc
Print an object returned from the cache.
drush_cache_set in commands/core/cache.drush.inc
Set an object in the cache.

... See full list

File

includes/context.inc, line 377
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;
}