1. 6.x docs/context.html
  2. 4.x docs/context.html
  3. 5.x docs/context.html


View source
<h1>Drush Contexts</h1>
The drush contexts API acts as a storage mechanism for all options, 
arguments and configuration settings that are loaded into drush.
This API also acts as an IPC mechanism between the different drush commands,
and provides protection from accidentally overriding settings that are
needed by other parts of the system.
It also avoids the necessity to pass references through the command chain
and allows the scripts to keep track of whether any settings have changed
since the previous execution.
This API defines several contexts that are used by default.

<h2>Argument contexts</h2>
These contexts are used by Drush to store information on the command.
They have their own access functions in the forms of
drush_set_arguments(), drush_get_arguments(), drush_set_command(),
<li>command : The drush command being executed.</li>
<li>arguments : Any additional arguments that were specified.</li>

<h2>Setting contexts</h2>
These contexts store options that have been passed to the drush.php
script, either through the use of any of the config files, directly from
the command line through --option='value' or through a JSON encoded string
passed through the STDIN pipe.
These contexts are accessible through the drush_get_option() and
drush_set_option() functions.  See drush_context_names() for a description
of all of the contexts.
Drush commands may also choose to save settings for a specific context to
the matching configuration file through the drush_save_config() function.

<h2>Available Setting contexts</h2>
These contexts are evaluated in a certain order, and the highest priority value
is returned by default from drush_get_option. This allows scripts to check whether
an option was different before the current execution.
Specified by the script itself :
<li>process  : Generated in the current process.
<li>cli      : Passed as --option=value to the command line.
<li>stdin    : Passed as a JSON encoded string through stdin.
<li>alias    : Defined in an alias record, and set in the
               alias context whenever that alias is used.
<li>specific : Defined in a command-specific option record, and
               set in the command context whenever that command is used.
Specified by config files :

<li>custom   : Loaded from the config file specified by --config or -c
<li>site     : Loaded from the drushrc.php file in the Drupal site directory.
<li>drupal   : Loaded from the drushrc.php file in the Drupal root directory.
<li>user     : Loaded from the drushrc.php file in the user's home directory.
<li>drush    : Loaded from the drushrc.php file in the $HOME/.drush directory.
<li>system   : Loaded from the drushrc.php file in the system's $PREFIX/etc/drush directory.
<li>drush    : Loaded from the drushrc.php file in the same directory as drush.php.
Specified by the script, but has the lowest priority :
<li>default  : The script might provide some sensible defaults during init.