Skip to content

Commit

Permalink
breaking: update some toolkit deps to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 5, 2021
1 parent 2c35c38 commit ee9ce7f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 20 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/Controller/ShowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/AbstractApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}

Expand Down
3 changes: 2 additions & 1 deletion src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
13 changes: 2 additions & 11 deletions src/Util/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ee9ce7f

Please sign in to comment.