Skip to content

Commit 63aba9c

Browse files
committed
some update
1 parent 28b58dd commit 63aba9c

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/Base/AbstractApplication.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
*/
2020
abstract class AbstractApplication implements ApplicationInterface
2121
{
22-
use InputOutputTrait;
23-
use SimpleEventTrait;
22+
use InputOutputTrait, SimpleEventTrait;
2423

2524
/** @var bool render no color */
2625
private static $noColor = false;
@@ -363,7 +362,7 @@ public function showCommandList($quit = true)
363362
$this->output->mList([
364363
//'There are all console controllers and independent commands.',
365364
'Usage:' => "$script [route|command] [arg0 arg1=value1 arg2=value2 ...] [--opt -v -h ...]",
366-
'Group Commands:(by controller)' => $controllerArr ?: '... No register any group command(controller)',
365+
'Group Commands:' => $controllerArr ?: '... No register any group command(controller)',
367366
'Independent Commands:' => $commandArr ?: '... No register any independent command',
368367
'Internal Commands:' => $internalCommands,
369368
'Internal Options:' => self::$internalOptions

src/Controller.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ final protected function showCommandList()
148148
$ref = new \ReflectionClass($this);
149149
$sName = lcfirst(self::getName() ?: $ref->getShortName());
150150

151-
// $this->write(sprintf("This is in the console controller [<bold>%s</bold>]\n", $class = $ref->getName();));
152-
153151
if (!($classDes = self::getDescription())) {
154152
$classDes = Annotation::description($ref->getDocComment()) ?: 'No Description for the console controller';
155153
}
@@ -182,25 +180,37 @@ final protected function showCommandList()
182180
}
183181
}
184182

183+
// sort commands
184+
ksort($commands);
185+
186+
// move 'help' to last.
187+
if ($helpCmd = $commands['help'] ?? null) {
188+
unset($commands['help']);
189+
$commands['help'] = $helpCmd;
190+
}
191+
192+
$script = $this->getScriptName();
193+
185194
if ($this->standAlone) {
186195
$name = $sName . ' ';
187-
$usage = '<info>{command}</info> [arguments] [options]';
196+
$usage = "$script <info>{command}</info> [arguments] [options]";
188197
} else {
189198
$name = $sName . $this->delimiter;
190-
$usage = "<info>{$name}</info>{command} [arguments] [options]";
199+
$usage = "$script {$name}<info>{command}</info> [arguments] [options]";
191200
}
192201

193-
$script = $this->getScriptName();
194202
$this->output->mList([
195203
'Description:' => $classDes,
196204
'Usage:' => $usage,
197205
//'Group Name:' => "<info>$sName</info>",
198206
'Commands:' => $commands,
199207
'Options:' => [
200208
'-h,--help' => 'Show help of the command group or specified command action',
201-
$this->showMore ? "\nMore information please use: <cyan>$script {$name}{command} -h</cyan>" : ''
209+
// $this->showMore ? "\nMore information please use: <cyan>$script {$name}{command} -h</cyan>" : ''
202210
],
203211
]);
212+
213+
$this->showMore && $this->write("More information please use: <cyan>$script {$name}{command} -h</cyan>");
204214
}
205215

206216
/**

0 commit comments

Comments
 (0)