mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
CLISetup/Fixup
* also convert Cfg test function, forgotten in 2386e35207
This commit is contained in:
@@ -212,7 +212,7 @@ class Cfg
|
||||
{
|
||||
$errMsg = '';
|
||||
if (!method_exists('Cfg', $key))
|
||||
$errMsg = 'required onSetFN validator not set';
|
||||
$errMsg = 'Aowow config '.strtoupper($key).' flagged for onSetFN validation, but no handler was set';
|
||||
else
|
||||
self::{$key}($value, $errMsg);
|
||||
|
||||
@@ -387,12 +387,8 @@ class Cfg
|
||||
if (!CLI)
|
||||
return true;
|
||||
|
||||
CLISetup::$localeIds = [];
|
||||
foreach (CLISetup::$locales as $idx => $_)
|
||||
if (!($value) || ($value & (1 << $idx)))
|
||||
CLISetup::$localeIds[] = $idx;
|
||||
|
||||
if (!empty(CLISetup::$localeIds))
|
||||
// note: Change is written to db and storage at this point, but can be rolled back.
|
||||
if (CLISetup::setLocales())
|
||||
return true;
|
||||
|
||||
$msg .= 'no valid locales set';
|
||||
|
||||
@@ -170,18 +170,8 @@ class CLISetup
|
||||
yield $name => [$src, $ref];
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
public static function setLocales() : bool
|
||||
{
|
||||
self::evalOpts();
|
||||
|
||||
// optional logging
|
||||
if (isset(self::$opts['log']))
|
||||
CLI::initLogFile(trim(self::$opts['log']));
|
||||
|
||||
// alternative data source (no quotes, use forward slash)
|
||||
if (isset(self::$opts['datasrc']))
|
||||
self::$srcDir = CLI::nicePath(self::$opts['datasrc']);
|
||||
|
||||
// optional limit handled locales
|
||||
if (isset(self::$opts['locales']))
|
||||
{
|
||||
@@ -201,7 +191,22 @@ class CLISetup
|
||||
if (($l = Cfg::get('LOCALES')) && !($l & (1 << $idx)))
|
||||
unset(self::$locales[$idx]);
|
||||
|
||||
if (!self::$locales)
|
||||
return !!self::$locales;
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
self::evalOpts();
|
||||
|
||||
// optional logging
|
||||
if (isset(self::$opts['log']))
|
||||
CLI::initLogFile(trim(self::$opts['log']));
|
||||
|
||||
// alternative data source (no quotes, use forward slash)
|
||||
if (isset(self::$opts['datasrc']))
|
||||
self::$srcDir = CLI::nicePath(self::$opts['datasrc']);
|
||||
|
||||
if (!self::setLocales())
|
||||
CLI::write('No valid locale specified. Check your config or --locales parameter, if used', CLI::LOG_ERROR);
|
||||
|
||||
// get site status
|
||||
|
||||
Reference in New Issue
Block a user