From bc9b70508edf224a15a3bdb45998f7fd75847765 Mon Sep 17 00:00:00 2001 From: Aviv Eyal Date: Wed, 15 Feb 2017 13:38:57 +0000 Subject: [PATCH] arc set-config: warn about unknown keys Summary: See T12266. Warn when the user tries to set a value we will probably not read. Test Plan: `arc set-config foo bar`, see fancy warning. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D17357 --- src/workflow/ArcanistSetConfigWorkflow.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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 @@ -69,6 +69,16 @@ EOTEXT $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]; @@ -85,12 +95,12 @@ EOTEXT $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, @@ -110,13 +120,13 @@ EOTEXT $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,