diff --git a/README.md b/README.md index e48ac21..ff99a46 100644 --- a/README.md +++ b/README.md @@ -282,4 +282,5 @@ $reader->read('abc', 'trim'); ### Related -- [adhocore/phalcon-ext](https://github.com/adhocore/phalcon-ext) +- [adhocore/phalcon-ext](https://github.com/adhocore/phalcon-ext) Phalcon extension using `adhocore/cli` +- [adhocore/phint](https://github.com/adhocore/phint) PHP project scaffolding app using `adhocore/cli` diff --git a/src/Input/Command.php b/src/Input/Command.php index 5bb3847..e70aa19 100644 --- a/src/Input/Command.php +++ b/src/Input/Command.php @@ -315,6 +315,10 @@ public function showHelp() ->showArgumentsHelp($this->allArguments()) ->showOptionsHelp($this->allOptions(), '', 'Legend: [optional]'); + if ($this->_usage) { + $writer->eol()->greenBold('Usage Examples:', true)->raw(\trim($this->_usage))->eol(); + } + return $this->emit('_exit', 0); } diff --git a/tests/Input/DefaultOptionTest.php b/tests/Input/DefaultOptionTest.php index cc95574..7225a5a 100644 --- a/tests/Input/DefaultOptionTest.php +++ b/tests/Input/DefaultOptionTest.php @@ -22,12 +22,16 @@ public function test_V() public function test_help() { $p = $this->newCommand() - ->arguments('[arg]') + ->argument('[arg]', 'Some desc') ->option('-o --option') + ->usage('cmdname --option opt ') ->parse(['php', '--help']); $this->assertContains('cmdname', $buffer = $this->buffer()); + $this->assertContains('Usage Examples:', $buffer); + $this->assertContains('--option opt ', $buffer); $this->assertContains('[arg]', $buffer); + $this->assertContains('Some desc', $buffer); $this->assertContains('[-o|--option]', $buffer); }