From 4d306e64fb0f9c5934d80fde58da31023dd8e44d Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Mon, 1 Jul 2024 19:00:26 +0200 Subject: [PATCH] CLI/Config * fixed skipping the value in oneline mode being interpreted as empty string * fixed entering infinite loop in oneline mode, when passed value was invalid * fixed displaying config hint, when passed value was valid --- setup/tools/clisetup/siteconfig.us.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/setup/tools/clisetup/siteconfig.us.php b/setup/tools/clisetup/siteconfig.us.php index 45c05550..fe692b78 100644 --- a/setup/tools/clisetup/siteconfig.us.php +++ b/setup/tools/clisetup/siteconfig.us.php @@ -44,7 +44,7 @@ CLISetup::registerUtility(new class extends UtilityScript switch (strtoupper($action)) { case 'E': - $result = $this->doEdit($name, $value); + $result = $this->doEdit($name, $args[2]); break; case 'R': $result = $this->doRestore($name); @@ -146,7 +146,7 @@ CLISetup::registerUtility(new class extends UtilityScript $setting = array( 'key' => ['option name', false, false, Cfg::PATTERN_CONF_KEY], - 'val' => ['value', ] + 'val' => ['value'] ); if (CLI::read($setting, $uiSetting) && $uiSetting) $this->doNew($uiSetting['key'], $uiSetting['val']); @@ -226,19 +226,19 @@ CLISetup::registerUtility(new class extends UtilityScript foreach (explode(', ', $info[1]) as $option) { [$val, $name] = explode(':', $option); - CLI::write('['.CLI::bold($val).'] '.$name); + $typeHint[] = '['.CLI::bold($val).'] '.$name; } $single = true; $pattern = '/^\d$/'; } else if ($flags & Cfg::FLAG_BITMASK) { - $typeHint[] = 'Bitmask: sum fields to select multiple options'; foreach (explode(', ', $info[1]) as $option) { [$val, $name] = explode(':', $option); - CLI::write('['.CLI::bold(1 << $val).']'.str_pad('', 6 - strlen(1 << $val)).$name); + $typeHint[] = '['.CLI::bold(1 << $val).']'.str_pad('', 6 - strlen(1 << $val)).$name; } + $typeHint[] = 'Bitmask: sum fields to select multiple options'; $pattern = '/^\d+$/'; } else if ($flags & Cfg::FLAG_TYPE_BOOL) @@ -265,6 +265,8 @@ CLISetup::registerUtility(new class extends UtilityScript CLI::write(); $val = $newVal ?? $uiValue['idx'] ?? ''; + unset($newVal); // we loop infinitely if this is set and invalid + if ($err = Cfg::set($key, $val, $this->updScripts)) { CLI::write($err, CLI::LOG_ERROR);