From ae9e9f615b2c5de2e3b05f61b7d09c7bcb85fc54 Mon Sep 17 00:00:00 2001 From: Inhere Date: Thu, 9 Dec 2021 14:41:19 +0800 Subject: [PATCH] up: update dep toolkit/pflag to 2.0 --- composer.json | 4 ++-- src/AbstractApplication.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 23e2873..a1f57a5 100644 --- a/composer.json +++ b/composer.json @@ -22,10 +22,10 @@ } ], "require": { - "php": ">=8.0.1", + "php": ">8.0.1", "toolkit/cli-utils": "~2.0", "toolkit/fsutil": "~2.0", - "toolkit/pflag": "~1.0", + "toolkit/pflag": "~2.0", "toolkit/stdlib": "^2.0", "toolkit/sys-utils": "~2.0" }, diff --git a/src/AbstractApplication.php b/src/AbstractApplication.php index efef96f..a415c38 100644 --- a/src/AbstractApplication.php +++ b/src/AbstractApplication.php @@ -261,8 +261,14 @@ protected function beforeRun(): bool $firstArg = array_shift($remainArgs); if (!Helper::isValidCmdPath($firstArg)) { - $this->output->liteError('input an invalid command name'); - $this->showCommandList(); + $evtName = ConsoleEvent::ON_NOT_FOUND; + if (true === $this->fire($evtName, $firstArg, $this)) { + $this->debugf('user custom handle the invalid command: %s, event: %s', $firstArg, $evtName); + } else { + $this->output->liteError("input an invalid command name: $firstArg"); + $this->showCommandList(); + } + return false; }