Skip to content

Commit 05a4337

Browse files
committed
enhance: will display group options on group/command help
1 parent c605220 commit 05a4337

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

src/Concern/AttachApplicationTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public function isInteractive(): bool
8484
}
8585

8686
$value = $this->input->getBoolOpt(GlobalOption::NO_INTERACTIVE);
87-
8887
return $value === false;
8988
}
9089

src/Concern/CommandHelpTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ protected function showHelpByAnnotations(string $method, string $action = '', ar
209209
}
210210

211211
// is an command object
212-
$isCommand = $this->isCommand();
212+
$isCommand = $this->isAlone();
213213
foreach ($allowedTags as $tag) {
214214
if (empty($tags[$tag]) || !is_string($tags[$tag])) {
215215
// for alone command

src/Concern/ControllerHelpTrait.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,14 @@ public function showCommandList(): void
150150
$name = $sName . $this->delimiter;
151151
// $usage = "$script {$name}<info>{command}</info> [--options ...] [arguments ...]";
152152
$usage = [
153-
"$script $name<info>COMMAND</info> [--options ...] [arguments ...]",
154-
"$script $sName <info>COMMAND</info> [--options ...] [arguments ...]",
153+
"$script [--global options] $sName [--group options] <info>COMMAND</info> [--options ...] [arguments ...]",
154+
"$script [--global options] $name<info>COMMAND</info> [--options ...] [arguments ...]",
155155
];
156156
}
157157

158-
$globalOptions = static::$globalOptions;
158+
$globalOptions = [];
159159
if ($app = $this->getApp()) {
160-
$globalOptions = array_merge(
161-
$app->getFlags()->getOptsHelpData(),
162-
static::$globalOptions
163-
);
160+
$globalOptions = $app->getFlags()->getOptsHelpData();
164161
}
165162

166163
$this->output->startBuffer();
@@ -170,16 +167,18 @@ public function showCommandList(): void
170167
$this->output->writef("<comment>Alias:</comment> %s\n", implode(',', $aliases));
171168
}
172169

170+
$groupOptions = $this->flags->getOptsHelpData();
173171
$this->output->mList([
174172
'Usage:' => $usage,
175173
//'Group Name:' => "<info>$sName</info>",
174+
'Group Options:' => FormatUtil::alignOptions($groupOptions),
176175
'Global Options:' => FormatUtil::alignOptions($globalOptions),
177176
'Available Commands:' => $commands,
178177
], [
179178
'sepChar' => ' ',
180179
]);
181180

182-
$msgTpl = 'More information about a command, please see: <cyan>%s %s {command} -h</cyan>';
181+
$msgTpl = 'More information about a command, please see: <cyan>%s %s COMMAND -h</cyan>';
183182
$this->output->write(sprintf($msgTpl, $script, $detached ? '' : $sName));
184183
$this->output->flush();
185184
}

src/Concern/SubCommandsWareTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function addCommands(array $commands): void
167167
*
168168
* @return bool
169169
*/
170-
public function isSubCommand(string $name): bool
170+
public function isSub(string $name): bool
171171
{
172172
return isset($this->commands[$name]);
173173
}

src/GlobalOption.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class GlobalOption
5151
'--ishell' => 'bool;Run application an interactive shell environment',
5252
'--profile' => 'bool;Display timing and memory usage information',
5353
'--no-color' => 'bool;Disable color/ANSI for message output',
54-
'--help' => 'bool;Display this help message;;;h',
54+
'--help' => 'bool;Display application help message;;;h',
5555
'--version' => 'bool;Show application version information;;;V',
5656
'--no-interactive' => 'bool;Run commands in a non-interactive environment',
5757
];
@@ -78,7 +78,7 @@ class GlobalOption
7878
* @var array common options for the group/command
7979
*/
8080
protected static $commonOptions = [
81-
self::HELP => 'bool;Display this help message;;;h',
81+
self::HELP => 'bool;Display command help message;;;h',
8282
];
8383

8484
/**

0 commit comments

Comments
 (0)