You are here

function key_drush_command in Key 8

Same name and namespace in other branches
  1. 7.3 drush/key.drush.inc \key_drush_command()

Implements hook_drush_command().

File

drush/key.drush.inc, line 24
Drush 8 commands.

Code

function key_drush_command() {
  $items['key-save'] = [
    'description' => dt('Save a key.'),
    'examples' => [
      'drush key-save secret_password \'pA$$w0rd\' --label="Secret password" --key-type=authentication --key-provider=config --key-input=text_field' => 'Define a key for a password to use for authentication using the Configuration key provider.',
      'drush key-save encryption_key --label="Encryption key" --key-type=encryption --key-type-settings=\'{"key_size":256}\' --key-provider=file --key-provider-settings=\'{"file_location":"private://keys/encryption.key", "base64_encoded":true}\' --key-input=none' => 'Define a key to use for encryption using the File key provider.',
    ],
    'arguments' => [
      'id' => dt('The ID (machine name) of the key to save.'),
      'key_value' => dt('A key value to save. May or may not be allowed or required, depending on the key provider'),
    ],
    'required-arguments' => 1,
    'options' => key_drush_save_options(),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
  ];
  $items['key-delete'] = [
    'description' => dt('Delete a key.'),
    'arguments' => [
      'id' => dt('The ID (machine name) of the key to delete.'),
    ],
    'required-arguments' => TRUE,
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
  ];
  $items['key-list'] = [
    'description' => dt('Display a list of available keys.'),
    'options' => [
      'key-type' => [
        'description' => dt('An optional, comma-delimited list of key types. To see a list of available key types, use `drush key-type-list`.'),
        'example-value' => 'authentication,encryption',
      ],
      'key-provider' => [
        'description' => dt('An optional, comma-delimited list of key providers. To see a list of available key providers, use `drush key-provider-list`.'),
        'example-value' => 'config,file',
      ],
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'outputformat' => [
      'default' => 'table',
      'pipe-format' => 'list',
      'field-labels' => [
        'id' => 'ID',
        'label' => 'Label',
        'key_type' => 'Type',
        'key_provider' => 'Provider',
      ],
      'output-data-type' => 'format-table',
    ],
  ];
  $items['key-type-list'] = [
    'description' => dt('Display a list of available key types.'),
    'options' => [
      'group' => [
        'description' => dt('An optional key type group on which to filter.'),
        'example-value' => 'authentication,encryption',
      ],
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'outputformat' => [
      'default' => 'table',
      'pipe-format' => 'list',
      'field-labels' => [
        'id' => 'ID',
        'description' => 'Description',
      ],
      'output-data-type' => 'format-table',
    ],
  ];
  $items['key-provider-list'] = [
    'description' => dt('Display a list of available key providers.'),
    'options' => [
      'storage-method' => [
        'description' => dt('An optional key provider storage method on which to filter.'),
        'example-value' => 'config,file',
      ],
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'outputformat' => [
      'default' => 'table',
      'pipe-format' => 'list',
      'field-labels' => [
        'id' => 'ID',
        'description' => 'Description',
      ],
      'output-data-type' => 'format-table',
    ],
  ];
  $items['key-value-get'] = [
    'description' => dt('Get a key value.'),
    'arguments' => [
      'id' => dt('The ID (machine name) of the key whose value should be retrieved.'),
    ],
    'required-arguments' => TRUE,
    'options' => [
      'base64' => dt('Base64-encode the key value. This is useful in the case of binary encryption keys that would otherwise not be displayed in a readable way.'),
      'pipe' => dt('Print just the key value, and nothing else.'),
    ],
    'aliases' => [
      'key-value',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
    'outputformat' => [
      'default' => 'key-value',
      'pipe-format' => 'string',
      'label' => 'Key value',
      'output-data-type' => 'format-single',
    ],
  ];
  return $items;
}