From fdcf1c678a2e04d2ac2bcc3e60601401fe6084bb Mon Sep 17 00:00:00 2001 From: Inhere Date: Tue, 10 May 2022 13:24:30 +0800 Subject: [PATCH] fix: fix some error for run sub cmd --- src/Decorate/CommandHelpTrait.php | 12 ++++++------ src/Decorate/SubCommandsWareTrait.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Decorate/CommandHelpTrait.php b/src/Decorate/CommandHelpTrait.php index bb5ebad..db90e1b 100644 --- a/src/Decorate/CommandHelpTrait.php +++ b/src/Decorate/CommandHelpTrait.php @@ -136,12 +136,11 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri $binName = $this->input->getBinName(); $cmdPath = $binName . ' ' . $this->getPath(); - // if ($action) { - // $group = $this->getGroupName(); - // $cmdPath = "$binName $group $action"; - // } - if ($this->hasSubs()) { + if ($action) { + // $group = $this->getGroupName(); + $cmdPath .= " $action"; + } elseif ($this->hasSubs()) { $cmdPath .= ' SUBCOMMAND'; } @@ -153,7 +152,8 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri $help['Options:'] = FlagUtil::alignOptions($fs->getOptsHelpLines()); $help['Argument:'] = $fs->getArgsHelpLines(); - if ($subCmds = $this->getSubsForHelp()) { + // fix: action should not have sub-commands + if (!$action && ($subCmds = $this->getSubsForHelp())) { // sort commands ksort($subCmds); $help['Commands:'] = $subCmds; diff --git a/src/Decorate/SubCommandsWareTrait.php b/src/Decorate/SubCommandsWareTrait.php index 2bf1493..8b8b39a 100644 --- a/src/Decorate/SubCommandsWareTrait.php +++ b/src/Decorate/SubCommandsWareTrait.php @@ -265,9 +265,9 @@ public function getRoot(): static } /** - * @return static|null + * @return AbstractHandler|null */ - public function getParent(): ?static + public function getParent(): ?AbstractHandler { return $this->parent; }