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.

157 calls to drush_get_option()
DrushMakeProject::applyPatches in commands/make/make.project.inc
Retrieve and apply any patches specified by the makefile to this project.
DrushMakeProject::make in commands/make/make.project.inc
Build a project.
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_build_drush_command in includes/environment.inc
Build a drush command suitable for use for drush to call itself e.g. in backend_invoke.

... See full list

File

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