Skip to content

Commit 0711cb7

Browse files
committed
some modify for input definition
1 parent 1c0b0fd commit 0711cb7

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

docs/input-output.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# input and output
2+
3+
## input
4+
5+
## output
6+
7+
### output buffer
8+
9+
how tu use
10+
11+
- use `Output`
12+
13+
```php
14+
// open buffer
15+
$this->output->startBuffer();
16+
17+
$this->output->write('message 0');
18+
$this->output->write('message 1');
19+
// ....
20+
$this->output->write('message n');
21+
22+
// stop and output buffer
23+
$this->output->stopBuffer();
24+
```
25+
26+
- use `Show`
27+
28+
```php
29+
// open buffer
30+
Show::startBuffer();
31+
32+
Show::write('message 0');
33+
Show::write('message 1');
34+
// ....
35+
Show::write('message n');
36+
37+
// stop and output buffer
38+
Show::stopBuffer();
39+
```

src/Base/AbstractCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ protected function showHelp()
186186
// 创建了 InputDefinition , 则使用它的信息。
187187
// 不会再解析和使用命令的注释。
188188
if ($def = $this->getDefinition()) {
189-
$this->output->mList($def->getSynopsis());
189+
$cmd = $this->input->getCommand();
190+
$spt = $this->input->getScript();
191+
192+
$info = $def->getSynopsis();
193+
$info['usage'] = "$spt $cmd ". $info['usage'];
194+
195+
$this->output->mList($info);
190196

191197
return true;
192198
}

src/IO/InputDefinition.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public function getSynopsis($short = false)
419419
);
420420
}
421421

422-
$shortcut = $option['shortcut'] ? sprintf('-%s|', $option['shortcut']) : '';
422+
$shortcut = $option['shortcut'] ? sprintf('-%s, ', $option['shortcut']) : '';
423423
$elements[] = sprintf('[%s--%s%s]', $shortcut, $name, $value);
424424

425425
$key = "{$shortcut}--{$name}";
@@ -449,7 +449,7 @@ public function getSynopsis($short = false)
449449
$args[$name] = $des;
450450
}
451451

452-
$opts['-h|--help'] = 'Show help information for the command';
452+
$opts['-h, --help'] = 'Show help information for the command';
453453

454454
return [
455455
'description' => $this->description,

0 commit comments

Comments
 (0)