function state_drush_command

8.0.x state.drush.inc state_drush_command()
7.x state.drush.inc state_drush_command()

Implementation of hook_drush_command().

File

commands/core/state.drush.inc, line 23
Provides State commands.

Code

function state_drush_command() {
  $items['state-get'] = array(
    'description' => 'Display a state value.',
    'arguments' => array(
      'key' => 'The key name.',
    ),
    'required-arguments' => 1,
    'examples' => array(
      'drush state-get system.cron_last' => 'Displays last cron run timestamp',
    ),
    'outputformat' => array(
      'default' => 'json',
      'pipe-format' => 'json',
    ),
    'aliases' => array('sget'),
    'core' => array('8+'),
  );

  $items['state-set'] = array(
    'description' => 'Set a state value.',
    'arguments' => array(
      'key' => 'The state key, for example "system.cron_last".',
      'value' => 'The value to assign to the state key. Use \'-\' to read from STDIN.',
    ),
    'required arguments' => 2,
    'options' => array(
      'format' => array(
        'description' => 'Type for  the value. Use "auto" to detect format from value. Other recognized values are string, integer float, or boolean for corresponding primitive type, or json, yaml for complex types.',
        'example-value' => 'boolean',
        'value' => 'required',
      ),
      
      // A convenient way to pass a multiline value within a backend request.
      'value' => array(
        'description' => 'The value to assign to the state key (if any).',
        'hidden' => TRUE,
      ),
    ),
    'examples' => array(
      'drush state-set system.cron_last 1406682882 --format=integer' => 'Sets a timestamp for last cron run.',
      'php -r "print json_encode(array(\'drupal\', \'simpletest\'));"  | drush state-set --format=json foo.name -' => 'Set a key to a complex value (e.g. array)',
    ),
    'aliases' => array('sset'),
    'core' => array('8+'),
  );

  $items['state-delete'] = array(
    'description' => 'Delete a state value.',
    'arguments' => array(
      'key' => 'The state key, for example "system.cron_last".',
    ),
    'required arguments' => 1,
    'examples' => array(
      'drush state-del system.cron_last' => 'Delete state entry for system.cron_last.',
    ),
    'aliases' => array('sdel'),
    'core' => array('8+'),
  );

  return $items;
}