Skip to content

Commit fdcf1c6

Browse files
committed
fix: fix some error for run sub cmd
1 parent a09383d commit fdcf1c6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Decorate/CommandHelpTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,11 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri
136136

137137
$binName = $this->input->getBinName();
138138
$cmdPath = $binName . ' ' . $this->getPath();
139-
// if ($action) {
140-
// $group = $this->getGroupName();
141-
// $cmdPath = "$binName $group $action";
142-
// }
143139

144-
if ($this->hasSubs()) {
140+
if ($action) {
141+
// $group = $this->getGroupName();
142+
$cmdPath .= " $action";
143+
} elseif ($this->hasSubs()) {
145144
$cmdPath .= ' <cyan>SUBCOMMAND</cyan>';
146145
}
147146

@@ -153,7 +152,8 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri
153152
$help['Options:'] = FlagUtil::alignOptions($fs->getOptsHelpLines());
154153
$help['Argument:'] = $fs->getArgsHelpLines();
155154

156-
if ($subCmds = $this->getSubsForHelp()) {
155+
// fix: action should not have sub-commands
156+
if (!$action && ($subCmds = $this->getSubsForHelp())) {
157157
// sort commands
158158
ksort($subCmds);
159159
$help['Commands:'] = $subCmds;

src/Decorate/SubCommandsWareTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ public function getRoot(): static
265265
}
266266

267267
/**
268-
* @return static|null
268+
* @return AbstractHandler|null
269269
*/
270-
public function getParent(): ?static
270+
public function getParent(): ?AbstractHandler
271271
{
272272
return $this->parent;
273273
}

0 commit comments

Comments
 (0)