diff --git a/src/workflow/ArcanistSetConfigWorkflow.php b/src/workflow/ArcanistSetConfigWorkflow.php index 9d9b099d..7bad38c1 100644 --- a/src/workflow/ArcanistSetConfigWorkflow.php +++ b/src/workflow/ArcanistSetConfigWorkflow.php @@ -1,131 +1,141 @@ array( 'help' => pht('Set a local config value instead of a user one.'), ), '*' => 'argv', ); } public function requiresRepositoryAPI() { return $this->getArgument('local'); } public function run() { $argv = $this->getArgument('argv'); if (count($argv) != 2) { throw new ArcanistUsageException( pht('Specify a key and a value.')); } $configuration_manager = $this->getConfigurationManager(); $is_local = $this->getArgument('local'); if ($is_local) { $config = $configuration_manager->readLocalArcConfig(); $which = 'local'; } else { $config = $configuration_manager->readUserArcConfig(); $which = 'user'; } $key = $argv[0]; $val = $argv[1]; $settings = new ArcanistSettings(); + $console = PhutilConsole::getConsole(); + + if (!$settings->getHelp($key)) { + $warn = pht( + 'The configuration key \'%s\' is not recognized by arc. It may '. + 'be misspelled or out of date.', + $key); + $console->writeErr("**%s:** %s\n", pht('Warning'), $warn); + } + $old = null; if (array_key_exists($key, $config)) { $old = $config[$key]; } if (!strlen($val)) { unset($config[$key]); if ($is_local) { $configuration_manager->writeLocalArcConfig($config); } else { $configuration_manager->writeUserArcConfig($config); } $old = $settings->formatConfigValueForDisplay($key, $old); if ($old === null) { - echo pht( + $console->writeOut( "Deleted key '%s' from %s config.\n", $key, $which); } else { - echo pht( + $console->writeOut( "Deleted key '%s' from %s config (was %s).\n", $key, $which, $old); } } else { $val = $settings->willWriteValue($key, $val); $config[$key] = $val; if ($is_local) { $configuration_manager->writeLocalArcConfig($config); } else { $configuration_manager->writeUserArcConfig($config); } $val = $settings->formatConfigValueForDisplay($key, $val); $old = $settings->formatConfigValueForDisplay($key, $old); if ($old === null) { - echo pht( + $console->writeOut( "Set key '%s' = %s in %s config.\n", $key, $val, $which); } else { - echo pht( + $console->writeOut( "Set key '%s' = %s in %s config (was %s).\n", $key, $val, $which, $old); } } return 0; } }