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(); $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("Deleted key '%s' from %s config.\n", $key, $which); } else { echo pht("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("Set key '%s' = %s in %s config.\n", $key, $val, $which); } else { echo pht("Set key '%s' = %s in %s config (was %s).\n", $key, $val, $which, $old); } } return 0; }
public function applyRuntimeArcConfig($args) { $arcanist_settings = new ArcanistSettings(); $options = $args->getArg('config'); foreach ($options as $opt) { $opt_config = preg_split('/=/', $opt, 2); if (count($opt_config) !== 2) { throw new ArcanistUsageException("Argument was '{$opt}', but must be " . "'name=value'. For example, history.immutable=true"); } list($key, $value) = $opt_config; $value = $arcanist_settings->willWriteValue($key, $value); $this->setRuntimeConfig($key, $value); } return $this->runtimeConfig; }
public function run() { if ($this->getArgument('show')) { return $this->show(); } $argv = $this->getArgument('argv'); if (count($argv) != 2) { throw new ArcanistUsageException("Specify a key and a value, or --show."); } $is_local = $this->getArgument('local'); if ($is_local) { $config = $this->readLocalArcConfig(); $which = 'local'; } else { $config = self::readGlobalArcConfig(); $which = 'global'; } $key = $argv[0]; $val = $argv[1]; $settings = new ArcanistSettings(); $old = null; if (array_key_exists($key, $config)) { $old = $config[$key]; } if (!strlen($val)) { unset($config[$key]); if ($is_local) { $this->writeLocalArcConfig($config); } else { self::writeGlobalArcConfig($config); } $old = $settings->formatConfigValueForDisplay($key, $old); if ($old === null) { echo "Deleted key '{$key}' from {$which} config.\n"; } else { echo "Deleted key '{$key}' from {$which} config (was {$old}).\n"; } } else { $val = $settings->willWriteValue($key, $val); $config[$key] = $val; if ($is_local) { $this->writeLocalArcConfig($config); } else { self::writeGlobalArcConfig($config); } $val = $settings->formatConfigValueForDisplay($key, $val); $old = $settings->formatConfigValueForDisplay($key, $old); if ($old === null) { echo "Set key '{$key}' = {$val} in {$which} config.\n"; } else { echo "Set key '{$key}' = {$val} in {$which} config (was {$old}).\n"; } } return 0; }