enhance config-services script a bit
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -256,6 +256,10 @@ class Action
|
||||
echo PHP_EOL;
|
||||
CmdLineHandler::printsucc("You can now apply this config running:" . PHP_EOL . "php " . __FILE__ . " --froxlor-dir=" . dirname(dirname(__DIR__)) . " --apply=" . $output);
|
||||
echo PHP_EOL;
|
||||
$proceed = CmdLineHandler::getYesNo("Do you want to apply the config now? [y/N]", 0);
|
||||
if ($proceed) {
|
||||
passthru("php " . __FILE__ . " --froxlor-dir=" . dirname(dirname(__DIR__)) . " --apply=" . $output);
|
||||
}
|
||||
}
|
||||
|
||||
private function getCompleteDistroName($cparser)
|
||||
|
||||
@@ -169,6 +169,35 @@ abstract class CmdLineHandler
|
||||
return mb_strtolower($result);
|
||||
}
|
||||
|
||||
public static function getYesNo($prompt = "#", $default = null)
|
||||
{
|
||||
$value = null;
|
||||
$_v = null;
|
||||
|
||||
while (true) {
|
||||
$_v = self::getInput($prompt);
|
||||
|
||||
if (strtolower($_v) == 'y' || strtolower($_v) == 'yes') {
|
||||
$value = 1;
|
||||
break;
|
||||
} elseif (strtolower($_v) == 'n' || strtolower($_v) == 'no') {
|
||||
$value = 0;
|
||||
break;
|
||||
} else {
|
||||
if ($_v == '' && $default != null) {
|
||||
$value = $default;
|
||||
break;
|
||||
} else {
|
||||
echo "Sorry, response " . $_v . " not understood. Please enter 'yes' or 'no'\n";
|
||||
$value = null;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public static function println($msg = "")
|
||||
{
|
||||
print $msg . PHP_EOL;
|
||||
|
||||
Reference in New Issue
Block a user