Skip to content

Commit

Permalink
enhance: will display group options on group/command help
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Sep 24, 2021
1 parent c605220 commit 05a4337
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/Concern/AttachApplicationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public function isInteractive(): bool
}

$value = $this->input->getBoolOpt(GlobalOption::NO_INTERACTIVE);

return $value === false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Concern/CommandHelpTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected function showHelpByAnnotations(string $method, string $action = '', ar
}

// is an command object
$isCommand = $this->isCommand();
$isCommand = $this->isAlone();
foreach ($allowedTags as $tag) {
if (empty($tags[$tag]) || !is_string($tags[$tag])) {
// for alone command
Expand Down
15 changes: 7 additions & 8 deletions src/Concern/ControllerHelpTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,14 @@ public function showCommandList(): void
$name = $sName . $this->delimiter;
// $usage = "$script {$name}<info>{command}</info> [--options ...] [arguments ...]";
$usage = [
"$script $name<info>COMMAND</info> [--options ...] [arguments ...]",
"$script $sName <info>COMMAND</info> [--options ...] [arguments ...]",
"$script [--global options] $sName [--group options] <info>COMMAND</info> [--options ...] [arguments ...]",
"$script [--global options] $name<info>COMMAND</info> [--options ...] [arguments ...]",
];
}

$globalOptions = static::$globalOptions;
$globalOptions = [];
if ($app = $this->getApp()) {
$globalOptions = array_merge(
$app->getFlags()->getOptsHelpData(),
static::$globalOptions
);
$globalOptions = $app->getFlags()->getOptsHelpData();
}

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

$groupOptions = $this->flags->getOptsHelpData();
$this->output->mList([
'Usage:' => $usage,
//'Group Name:' => "<info>$sName</info>",
'Group Options:' => FormatUtil::alignOptions($groupOptions),
'Global Options:' => FormatUtil::alignOptions($globalOptions),
'Available Commands:' => $commands,
], [
'sepChar' => ' ',
]);

$msgTpl = 'More information about a command, please see: <cyan>%s %s {command} -h</cyan>';
$msgTpl = 'More information about a command, please see: <cyan>%s %s COMMAND -h</cyan>';
$this->output->write(sprintf($msgTpl, $script, $detached ? '' : $sName));
$this->output->flush();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Concern/SubCommandsWareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function addCommands(array $commands): void
*
* @return bool
*/
public function isSubCommand(string $name): bool
public function isSub(string $name): bool
{
return isset($this->commands[$name]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/GlobalOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GlobalOption
'--ishell' => 'bool;Run application an interactive shell environment',
'--profile' => 'bool;Display timing and memory usage information',
'--no-color' => 'bool;Disable color/ANSI for message output',
'--help' => 'bool;Display this help message;;;h',
'--help' => 'bool;Display application help message;;;h',
'--version' => 'bool;Show application version information;;;V',
'--no-interactive' => 'bool;Run commands in a non-interactive environment',
];
Expand All @@ -78,7 +78,7 @@ class GlobalOption
* @var array common options for the group/command
*/
protected static $commonOptions = [
self::HELP => 'bool;Display this help message;;;h',
self::HELP => 'bool;Display command help message;;;h',
];

/**
Expand Down

0 comments on commit 05a4337

Please sign in to comment.