From 1ba90fb7103e8d2fd47667ec6079228922228c11 Mon Sep 17 00:00:00 2001 From: Jitendra Adhikari Date: Fri, 13 Jul 2018 07:23:28 +0700 Subject: [PATCH 1/3] feat(command): show usage examples if available --- src/Input/Command.php | 4 ++++ 1 file changed, 4 insertions(+) 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); } From c549e4da2551ff128b738fbf6facc3cb76c6be41 Mon Sep 17 00:00:00 2001 From: Jitendra Adhikari Date: Fri, 13 Jul 2018 07:23:45 +0700 Subject: [PATCH 2/3] test(command): usage example --- tests/Input/DefaultOptionTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); } From e0672a5921a171bb657cbcef009eb0e23327fdf1 Mon Sep 17 00:00:00 2001 From: Jitendra Adhikari Date: Fri, 13 Jul 2018 07:36:44 +0700 Subject: [PATCH 3/3] docs: add ref adhocore/phint [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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`