diff --git a/composer.json b/composer.json index 365f2be..23e2873 100644 --- a/composer.json +++ b/composer.json @@ -22,12 +22,12 @@ } ], "require": { - "php": ">=8.0", - "toolkit/cli-utils": "~1.0", - "toolkit/fsutil": "~1.0", + "php": ">=8.0.1", + "toolkit/cli-utils": "~2.0", + "toolkit/fsutil": "~2.0", "toolkit/pflag": "~1.0", - "toolkit/stdlib": "^1.0", - "toolkit/sys-utils": "~1.0" + "toolkit/stdlib": "^2.0", + "toolkit/sys-utils": "~2.0" }, "require-dev": { "phpunit/phpunit": "^9.1" diff --git a/examples/Controller/ShowController.php b/examples/Controller/ShowController.php index f5b0b92..3ea1a70 100644 --- a/examples/Controller/ShowController.php +++ b/examples/Controller/ShowController.php @@ -17,7 +17,7 @@ use Inhere\Console\Util\Show; use ReflectionException; use Toolkit\Cli\Color; -use Toolkit\Cli\Highlighter; +use Toolkit\Cli\Util\Highlighter; use Toolkit\PFlag\FlagsParser; use function file_get_contents; diff --git a/src/AbstractApplication.php b/src/AbstractApplication.php index 02323dc..efef96f 100644 --- a/src/AbstractApplication.php +++ b/src/AbstractApplication.php @@ -27,9 +27,9 @@ use InvalidArgumentException; use JetBrains\PhpStorm\NoReturn; use Throwable; -use Toolkit\Cli\Helper\FlagHelper; use Toolkit\Cli\Style; use Toolkit\Cli\Util\LineParser; +use Toolkit\PFlag\FlagUtil; use Toolkit\PFlag\SFlags; use Toolkit\Stdlib\Helper\DataHelper; use Toolkit\Stdlib\Helper\PhpHelper; @@ -485,7 +485,7 @@ protected function handleGlobalCommand(string $command): bool case 'help': $cmd = ''; $args = $this->flags->getRawArgs(); - if ($args && FlagHelper::isValidName($args[0])) { + if ($args && FlagUtil::isValidName($args[0])) { $cmd = $args[0]; } diff --git a/src/Controller.php b/src/Controller.php index 4aa3a80..559f076 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -26,6 +26,7 @@ use Throwable; use Toolkit\Cli\Helper\FlagHelper; use Toolkit\PFlag\FlagsParser; +use Toolkit\PFlag\FlagUtil; use Toolkit\PFlag\SFlags; use Toolkit\Stdlib\Obj\ObjectHelper; use Toolkit\Stdlib\Str; @@ -272,7 +273,7 @@ public function doRun(array $args): mixed } } else { $first = $args[0]; - if (!FlagHelper::isValidName($first)) { + if (!FlagUtil::isValidName($first)) { $this->debugf('not input subcommand, display help for the group: %s', $name); return $this->showHelp(); } diff --git a/src/Util/Show.php b/src/Util/Show.php index 9cd1a06..73cb3d6 100644 --- a/src/Util/Show.php +++ b/src/Util/Show.php @@ -646,21 +646,12 @@ public static function writef(string $format, ...$args): int * * @param array|string $messages Output message * @param boolean $nl True 会添加换行符, False 原样输出,不添加换行符 - * @param bool|int $quit If is int, setting it is exit code. 'True' translate as code 0 and exit, 'False' will not exit. + * @param bool $quit If is int, setting it is exit code. 'True' translate as code 0 and exit, 'False' will not exit. * @param array{color:bool,stream:resource,flush:bool,quit:bool,quitCode:int} $opts Some options for write - * refer: - * [ - * 'color' => bool, // whether render color, default is: True. - * 'stream' => resource, // the stream resource, default is: STDOUT - * 'flush' => bool, // flush the stream data, default is: True - * ] - * * @return int */ public static function write(array|string $messages, bool $nl = true, bool $quit = false, array $opts = []): int { - $qCode = $opts['quitCode'] ?? 0; - return Console::write($messages, $nl, $quit, $opts); } @@ -704,7 +695,7 @@ public static function writeln(array|string $message, bool $quit = false, array */ public static function colored(array|string $message, string $style = 'info', bool $nl = true, array $opts = []): int { - $quit = isset($opts['quit']) ? (bool)$opts['quit'] : false; + $quit = isset($opts['quit']) && $opts['quit']; if (is_array($message)) { $message = implode($nl ? PHP_EOL : '', $message);