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.

219 calls to drush_get_option()
DrupalBoot::bootstrap_drupal_login in lib/Drush/Boot/DrupalBoot.php
Log into the bootstrapped Drupal site with a specific username or user id.
druplicon_drush_exit in commands/core/druplicon.drush.inc
Implements hook_drush_exit().
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.
DrushMakeProject::processGitInfoFiles in commands/make/make.project.inc
Process info files when downloading things from git.

... See full list

File

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