function config_drush_command
8.0.x config.drush.inc | config_drush_command() |
7.x config.drush.inc | config_drush_command() |
master config.drush.inc | config_drush_command() |
Implementation of hook_drush_command().
File
- commands/
core/ config.drush.inc, line 32 - Provides Configuration Management commands.
Code
function config_drush_command() {
$items['config-get'] = array(
'description' => 'Display a config value, or a whole configuration object.',
'arguments' => array(
'config-name' => 'The config object name, for example "system.site".',
'key' => 'The config key, for example "page.front". Optional.',
),
'required-arguments' => 1,
'options' => array(
'source' => array(
'description' => 'The config storage source to read. Additional labels may be defined in settings.php',
'example-value' => 'sync',
'value' => 'required',
),
'include-overridden' => array(
'description' => 'Include overridden values.',
),
),
'examples' => array(
'drush config-get system.site' => 'Displays the system.site config.',
'drush config-get system.site page.front' => 'gets system.site:page.front value.',
),
'outputformat' => array(
'default' => 'yaml',
'pipe-format' => 'var_export',
),
'aliases' => array('cget'),
'core' => array('8+'),
);
$items['config-set'] = array(
'description' => 'Set config value directly.',
'arguments' => array(
'config-name' => 'The config object name, for example "system.site".',
'key' => 'The config key, for example "page.front".',
'value' => 'The value to assign to the config key. Use \'-\' to read from STDIN.',
),
'options' => array(
'format' => array(
'description' => 'Format to parse the object. Use "string" for string (default), and "yaml" for YAML.',
'example-value' => 'yaml',
'value' => 'required',
),
// A convenient way to pass a multiline value within a backend request.
'value' => array(
'description' => 'The value to assign to the config key (if any).',
'hidden' => TRUE,
),
),
'examples' => array(
'drush config-set system.site page.front node' => 'Sets system.site:page.front to "node".',
),
'aliases' => array('cset'),
'core' => array('8+'),
);
$items['config-export'] = array(
'description' => 'Export configuration to a directory.',
'core' => array('8+'),
'aliases' => array('cex'),
'arguments' => array(
'label' => "A config directory label (i.e. a key in \$config_directories array in settings.php). Defaults to 'sync'",
),
'options' => array(
'add' => 'Run `git add -p` after exporting. This lets you choose which config changes to sync for commit.',
'commit' => 'Run `git add -A` and `git commit` after exporting. This commits everything that was exported without prompting.',
'message' => 'Commit comment for the exported configuration. Optional; may only be used with --commit or --push.',
'push' => 'Run `git push` after committing. Implies --commit.',
'remote' => array(
'description' => 'The remote git branch to use to push changes. Defaults to "origin".',
'example-value' => 'origin',
),
'branch' => array(
'description' => 'Make commit on provided working branch. Ignored if used without --commit or --push.',
'example-value' => 'branchname',
),
'destination' => 'An arbitrary directory that should receive the exported files. An alternative to label argument.',
'skip-modules' => 'A list of modules to ignore during export (e.g. to avoid listing dev-only modules in exported configuration).',
),
'examples' => array(
'drush config-export --skip-modules=devel' => 'Export configuration; do not include the devel module in the exported configuration, regardless of whether or not it is enabled in the site.',
'drush config-export --destination' => 'Export configuration; Save files in a backup directory named config-export.',
),
);
$items['config-import'] = array(
'description' => 'Import config from a config directory.',
'arguments' => array(
'label' => "A config directory label (i.e. a key in \$config_directories array in settings.php). Defaults to 'sync'",
),
'options' => array(
'preview' => array(
'description' => 'Format for displaying proposed changes. Recognized values: list, diff. Defaults to list',
'example-value' => 'list',
),
'source' => 'An arbitrary directory that holds the configuration files. An alternative to label argument',
'partial' => 'Allows for partial config imports from the source directory. Only updates and new configs will be processed with this flag (missing configs will not be deleted).',
'skip-modules' => 'A list of modules to ignore during import (e.g. to avoid disabling dev-only modules that are not enabled in the imported configuration).',
),
'global-options' => array(
'cache-clear',
),
'core' => array('8+'),
'examples' => array(
'drush config-import --skip-modules=devel' => 'Import configuration; do not enable or disable the devel module, regardless of whether or not it appears in the imported list of enabled modules.',
),
'aliases' => array('cim'),
);
$items['config-list'] = array(
'description' => 'List config names by prefix.',
'core' => array('8+'),
'aliases' => array('cli'),
'arguments' => array(
'prefix' => 'The config prefix. For example, "system". No prefix will return all names in the system.',
),
'examples' => array(
'drush config-list system' => 'Return a list of all system config names.',
'drush config-list "image.style"' => 'Return a list of all image styles.',
'drush config-list --format="json"' => 'Return all config names as json.',
),
'outputformat' => array(
'default' => 'list',
'pipe-format' => 'var_export',
'output-data-type' => 'format-list',
),
);
$items['config-edit'] = array(
'description' => 'Open a config file in a text editor. Edits are imported into active configration after closing editor.',
'core' => array('8+'),
'aliases' => array('cedit'),
'arguments' => array(
'config-name' => 'The config object name, for example "system.site".',
),
'options' => array(
'file' => 'Import from a file instead of interactively editing a given config.',
),
'global-options' => array('editor', 'bg'),
'examples' => array(
'drush config-edit image.style.large' => 'Edit the image style configurations.',
'drush config-edit' => 'Choose a config file to edit.',
'drush config-edit --choice=2' => 'Edit the second file in the choice list.',
'drush --bg config-edit image.style.large' => 'Return to shell prompt as soon as the editor window opens.',
),
);
$items['config-pull'] = array(
'description' => 'Export and transfer config from one environment to another.',
// 'core' => array('8+'), Operates on remote sites so not possible to declare this locally.
'drush dependencies' => array('config', 'core'), // core-rsync, core-execute.
'bootstrap' => DRUSH_BOOTSTRAP_NONE,
'aliases' => array('cpull'),
'arguments' => array(
'source' => 'A site-alias or the name of a subdirectory within /sites whose config you want to copy from.',
'target' => 'A site-alias or the name of a subdirectory within /sites whose config you want to replace.',
),
'required-arguments' => TRUE,
'allow-additional-options' => array(), // Most options from config-export and core-rsync unusable.
'examples' => array(
'drush config-pull @prod @stage' => "Export config from @prod and transfer to @stage.",
'drush config-pull @prod @self --label=vcs' => "Export config from @prod and transfer to the 'vcs' config directory of current site.",
),
'options' => array(
'safe' => 'Validate that there are no git uncommitted changes before proceeding',
'label' => "A config directory label (i.e. a key in \$config_directories array in settings.php). Defaults to 'sync'",
),
'topics' => array('docs-aliases', 'docs-config-exporting'),
);
return $items;
}