From ba7d179a8849e591392d35ebe08a4ff2b5f45969 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Fri, 18 Mar 2016 17:18:36 -0400 Subject: [PATCH] Remove --file option form config-edit It duplicates config-import --partial, and is buggy. A fix for --partial is coming in #2069 --- commands/core/config.drush.inc | 35 +++++----------------------------- tests/configTest.php | 19 ------------------ 2 files changed, 5 insertions(+), 49 deletions(-) diff --git a/commands/core/config.drush.inc b/commands/core/config.drush.inc index 8dd8f19587..4369e8d2a0 100644 --- a/commands/core/config.drush.inc +++ b/commands/core/config.drush.inc @@ -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.', @@ -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); @@ -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)) { diff --git a/tests/configTest.php b/tests/configTest.php index 4773e725ef..3b04df3808 100644 --- a/tests/configTest.php +++ b/tests/configTest.php @@ -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: test@testmail.example.org"; - $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,