From b10966f38036e6100f1a7411714679cb0d3f991a Mon Sep 17 00:00:00 2001 From: Inhere Date: Mon, 19 Sep 2022 12:41:58 +0800 Subject: [PATCH] up: update soem for gitlab and run command --- app/Console/Attach/Gitlab/MergeRequestCmd.php | 4 +- app/Console/Command/RunCommand.php | 43 +++++++++++-------- app/Http/WebApplication.php | 6 +++ 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/app/Console/Attach/Gitlab/MergeRequestCmd.php b/app/Console/Attach/Gitlab/MergeRequestCmd.php index 0a0c130..22d4ba8 100644 --- a/app/Console/Attach/Gitlab/MergeRequestCmd.php +++ b/app/Console/Attach/Gitlab/MergeRequestCmd.php @@ -94,7 +94,7 @@ protected function execute(Input $input, Output $output): mixed $srcBranch = $curBranch; } - $open = $fs->getOpt('open'); + $open = $gl->getRealBranchName($fs->getOpt('open')); // if input '@', 'head', use current branch name. if ($open) { if ($open === '@' || strtoupper($open) === 'HEAD') { @@ -159,7 +159,7 @@ protected function execute(Input $input, Output $output): mixed if ($open) { // $output->info('will auto open link on browser'); AppHelper::openBrowser($link); - $output->success('Complete'); + $output->success('Complete. at ' . date('Y-m-d H:i:s')); } else { $output->colored("PR LINK: "); $output->writeln(' ' . $link); diff --git a/app/Console/Command/RunCommand.php b/app/Console/Command/RunCommand.php index 3c9fc36..b55c33c 100644 --- a/app/Console/Command/RunCommand.php +++ b/app/Console/Command/RunCommand.php @@ -50,8 +50,7 @@ protected function beforeExecute(): bool /** * @options - * -l, --list List information for all scripts or script files. type: file, cmd(default) - * -s, --search Display all matched scripts by the input name + * -l, --list List information for all scripts or script files. type: file, cmd * -i, --info Show information for give script name or script file * --dry-run bool;Mock running, not real execute. * -p, --proxy bool;Enable proxy ENV setting @@ -199,24 +198,30 @@ private function listScripts(Output $output, string $name): void 'filterEmpty' => true, ]; - if ($name && $this->sr->isScriptName($name)) { - $desc = ''; - $item = $this->sr->getScript($name); - - // [_meta => [desc, ]] - if (is_array($item) && isset($item['_meta'])) { - $meta = $item['_meta']; - unset($item['_meta']); - - $desc = $meta['desc'] ?? ''; - // $output->colored(ucfirst($desc), 'cyan'); + if ($name) { + if ($this->sr->isScriptName($name)) { + $desc = ''; + $item = $this->sr->getScript($name); + + // [_meta => [desc, ]] + if (is_array($item) && isset($item['_meta'])) { + $meta = $item['_meta']; + unset($item['_meta']); + + $desc = $meta['desc'] ?? ''; + // $output->colored(ucfirst($desc), 'cyan'); + } + + $output->aList([ + 'name' => $name, + 'desc' => $desc, + 'command' => $item, + ], "Script: $name", $listOpt); + } else { + $matched = $this->sr->searchScripts($name); + $number = \count($matched); + $output->aList($matched, "'$name' matched scripts(number: $number)", $listOpt); } - - $output->aList([ - 'name' => $name, - 'desc' => $desc, - 'command' => $item, - ], "Script: $name", $listOpt); } else { $count = $this->sr->getScriptCount(); $output->aList($this->sr->getScripts(), "registered scripts(total: $count)", $listOpt); diff --git a/app/Http/WebApplication.php b/app/Http/WebApplication.php index 7bf6feb..687d77c 100644 --- a/app/Http/WebApplication.php +++ b/app/Http/WebApplication.php @@ -11,6 +11,7 @@ use Inhere\Kite\Concern\InitApplicationTrait; use Inhere\Kite\Kite; +use Inhere\Route\Dispatcher\Dispatcher; use Inhere\Route\Router; use PhpPkg\EasyTpl\EasyTemplate; use Throwable; @@ -98,6 +99,11 @@ public function run(): void try { $dispatcher = Kite::dispatcher(); + // 成功匹配路由 + $dispatcher->on(Dispatcher::ON_FOUND, function ($uri, $cb) { + Kite::logger()->debug("Matched uri path: $uri, setting callback is: " . is_string($cb) ? $cb : get_class($cb)); + }); + Kite::webRouter()->dispatch($dispatcher); } catch (Throwable $e) { (new ErrorHandler((bool)$this->params['debug']))->run($e);