Skip to content

Commit ee9ce7f

Browse files
committed
breaking: update some toolkit deps to 2.0
1 parent 2c35c38 commit ee9ce7f

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
}
2323
],
2424
"require": {
25-
"php": ">=8.0",
26-
"toolkit/cli-utils": "~1.0",
27-
"toolkit/fsutil": "~1.0",
25+
"php": ">=8.0.1",
26+
"toolkit/cli-utils": "~2.0",
27+
"toolkit/fsutil": "~2.0",
2828
"toolkit/pflag": "~1.0",
29-
"toolkit/stdlib": "^1.0",
30-
"toolkit/sys-utils": "~1.0"
29+
"toolkit/stdlib": "^2.0",
30+
"toolkit/sys-utils": "~2.0"
3131
},
3232
"require-dev": {
3333
"phpunit/phpunit": "^9.1"

examples/Controller/ShowController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Inhere\Console\Util\Show;
1818
use ReflectionException;
1919
use Toolkit\Cli\Color;
20-
use Toolkit\Cli\Highlighter;
20+
use Toolkit\Cli\Util\Highlighter;
2121
use Toolkit\PFlag\FlagsParser;
2222
use function file_get_contents;
2323

src/AbstractApplication.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
use InvalidArgumentException;
2828
use JetBrains\PhpStorm\NoReturn;
2929
use Throwable;
30-
use Toolkit\Cli\Helper\FlagHelper;
3130
use Toolkit\Cli\Style;
3231
use Toolkit\Cli\Util\LineParser;
32+
use Toolkit\PFlag\FlagUtil;
3333
use Toolkit\PFlag\SFlags;
3434
use Toolkit\Stdlib\Helper\DataHelper;
3535
use Toolkit\Stdlib\Helper\PhpHelper;
@@ -485,7 +485,7 @@ protected function handleGlobalCommand(string $command): bool
485485
case 'help':
486486
$cmd = '';
487487
$args = $this->flags->getRawArgs();
488-
if ($args && FlagHelper::isValidName($args[0])) {
488+
if ($args && FlagUtil::isValidName($args[0])) {
489489
$cmd = $args[0];
490490
}
491491

src/Controller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Throwable;
2727
use Toolkit\Cli\Helper\FlagHelper;
2828
use Toolkit\PFlag\FlagsParser;
29+
use Toolkit\PFlag\FlagUtil;
2930
use Toolkit\PFlag\SFlags;
3031
use Toolkit\Stdlib\Obj\ObjectHelper;
3132
use Toolkit\Stdlib\Str;
@@ -272,7 +273,7 @@ public function doRun(array $args): mixed
272273
}
273274
} else {
274275
$first = $args[0];
275-
if (!FlagHelper::isValidName($first)) {
276+
if (!FlagUtil::isValidName($first)) {
276277
$this->debugf('not input subcommand, display help for the group: %s', $name);
277278
return $this->showHelp();
278279
}

src/Util/Show.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -646,21 +646,12 @@ public static function writef(string $format, ...$args): int
646646
*
647647
* @param array|string $messages Output message
648648
* @param boolean $nl True 会添加换行符, False 原样输出,不添加换行符
649-
* @param bool|int $quit If is int, setting it is exit code. 'True' translate as code 0 and exit, 'False' will not exit.
649+
* @param bool $quit If is int, setting it is exit code. 'True' translate as code 0 and exit, 'False' will not exit.
650650
* @param array{color:bool,stream:resource,flush:bool,quit:bool,quitCode:int} $opts Some options for write
651-
* refer:
652-
* [
653-
* 'color' => bool, // whether render color, default is: True.
654-
* 'stream' => resource, // the stream resource, default is: STDOUT
655-
* 'flush' => bool, // flush the stream data, default is: True
656-
* ]
657-
*
658651
* @return int
659652
*/
660653
public static function write(array|string $messages, bool $nl = true, bool $quit = false, array $opts = []): int
661654
{
662-
$qCode = $opts['quitCode'] ?? 0;
663-
664655
return Console::write($messages, $nl, $quit, $opts);
665656
}
666657

@@ -704,7 +695,7 @@ public static function writeln(array|string $message, bool $quit = false, array
704695
*/
705696
public static function colored(array|string $message, string $style = 'info', bool $nl = true, array $opts = []): int
706697
{
707-
$quit = isset($opts['quit']) ? (bool)$opts['quit'] : false;
698+
$quit = isset($opts['quit']) && $opts['quit'];
708699

709700
if (is_array($message)) {
710701
$message = implode($nl ? PHP_EOL : '', $message);

0 commit comments

Comments
 (0)