Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove --file option form config-edit #2082

Merged
merged 1 commit into from
Mar 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 5 additions & 30 deletions commands/core/config.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ function config_drush_command() {
'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.',
Expand Down Expand Up @@ -696,12 +693,6 @@ function _drush_config_import_partial(FileStorage $source) {
* Edit command callback.
*/
function drush_config_edit($config_name = '') {
$file = drush_get_option('file', FALSE);
if (empty($config_name) && $file) {
// If not provided, assume config name from the given file.
$config_name = basename($file, '.yml');
}

// Identify and validate input.
if ($config_name) {
$config = Drupal::configFactory()->getEditable($config_name);
Expand All @@ -724,29 +715,13 @@ function drush_config_edit($config_name = '') {
$active_storage = $config->getStorage();
$contents = $active_storage->read($config_name);

// Write tmp YAML file for editing
$temp_storage = new FileStorage(drush_tempdir());
if ($file) {
$temp_storage->write($config_name, \Symfony\Component\Yaml\Yaml::parse(file_get_contents($file)));
// Show difference.
$existing = new FileStorage(drush_tempdir());
$existing->write($config_name, $contents);
// @todo Can DiffFormatter produce a CLI pretty diff?
drush_shell_exec('diff -u %s %s', $existing->getFilePath($config_name), $temp_storage->getFilePath($config_name));
$output = drush_shell_exec_output();
drush_print(implode("\n", $output));

if (!drush_confirm(dt('Keep these changes?'))) {
return drush_user_abort(dt('Config not edited.'));
}
}
else {
// Write tmp YAML file for editing.
$temp_storage->write($config_name, $contents);
$temp_storage->write($config_name, $contents);

// $filepath = drush_save_data_to_temp_file();
$exec = drush_get_editor();
drush_shell_exec_interactive($exec, $temp_storage->getFilePath($config_name));
}
// $filepath = drush_save_data_to_temp_file();
$exec = drush_get_editor();
drush_shell_exec_interactive($exec, $temp_storage->getFilePath($config_name));

// Perform import operation if user did not immediately exit editor.
if (!drush_get_option('bg', FALSE)) {
Expand Down
19 changes: 0 additions & 19 deletions tests/configTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,6 @@ function testConfigExportImport() {
$this->assertContains('tracker', $contents);
}

/**
* Tests editing config from a file (not interactively).
*/
public function testConfigEdit() {
// Write out edits to a file.
$config = "name: 'TEST NAME'\nmail: [email protected]";
$path = UNISH_SANDBOX . '/system.site.yml';
file_put_contents($path, $config);

$options = $this->options();
$options += array(
'file' => $path,
'yes' => NULL,
);
$this->drush('config-edit', array(), $options);
$this->drush('config-get', array('system.site'), $this->options());
$this->assertEquals($config, $this->getOutput());
}

function options() {
return array(
'yes' => NULL,
Expand Down