Skip to content

Commit 7f2ce6f

Browse files
committed
some logic update
1 parent 600a7f8 commit 7f2ce6f

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/AbstractApp.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ abstract class AbstractApp
3333
const ON_STOP_RUN = 'stopRun';
3434
const ON_NOT_FOUND = 'notFound';
3535

36+
/**
37+
* @var string
38+
*/
39+
public $delimiter = ':'; // '/' ':'
40+
3641
/**
3742
* app meta config
3843
* @var array
@@ -367,12 +372,13 @@ protected function validateName(string $name, $isGroup = false)
367372
public function showHelpInfo($quit = true)
368373
{
369374
$script = $this->input->getScript();
375+
$sep = $this->delimiter;
370376

371377
$this->output->helpPanel([
372378
'usage' => "$script [route|command] [arg0 arg1=value1 arg2=value2 ...] [--opt -v -h ...]",
373379
'example' => [
374380
"$script test (run a independent command)",
375-
"$script home/index (run a command of the group)"
381+
"$script home{$sep}index (run a command of the group)"
376382
]
377383
], $quit);
378384
}
@@ -384,9 +390,9 @@ public function showHelpInfo($quit = true)
384390
public function showVersionInfo($quit = true)
385391
{
386392
$date = date('Y-m-d');
387-
$name = $this->config('name', 'Console Application');
388-
$version = $this->config('version', 'Unknown');
389-
$publishAt = $this->config('publishAt', 'Unknown');
393+
$name = $this->getMeta('name', 'Console Application');
394+
$version = $this->getMeta('version', 'Unknown');
395+
$publishAt = $this->getMeta('publishAt', 'Unknown');
390396
$phpVersion = PHP_VERSION;
391397
$os = PHP_OS;
392398

@@ -440,9 +446,10 @@ public function showCommandList($quit = true)
440446
$commandArr[$name] = $desc;
441447
}
442448

443-
$this->output->write('There are all console controllers and independent commands.');
449+
// $this->output->write('There are all console controllers and independent commands.');
444450
$this->output->mList([
445451
//'There are all console controllers and independent commands.',
452+
'Usage:' => "$script [route|command] [arg0 arg1=value1 arg2=value2 ...] [--opt -v -h ...]",
446453
'Group Commands:(by controller)' => $controllerArr ?: '... No register any group command(controller)',
447454
'Independent Commands:' => $commandArr ?: '... No register any independent command',
448455
'Internal Commands:' => $internalCommands,
@@ -536,12 +543,16 @@ public function setMeta(array $meta)
536543
}
537544

538545
/**
539-
* get meta
546+
* get meta info
540547
* @return array
541548
*/
542-
public function getMeta()
549+
public function getMeta($name = null, $default = null)
543550
{
544-
return $this->meta;
551+
if (!$name) {
552+
return $this->meta;
553+
}
554+
555+
return $this->meta[$name] ?? $default;
545556
}
546557

547558
/**

src/App.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
*/
1515
class App extends AbstractApp
1616
{
17-
/**
18-
* @var string
19-
*/
20-
public $delimiter = ':'; // '/' ':'
21-
2217
/**
2318
* addCommand
2419
* @param string $name

0 commit comments

Comments
 (0)