From 70cfbaddca6326db22232961f8ec863c415ad810 Mon Sep 17 00:00:00 2001 From: Vivek Ghaisas Date: Mon, 5 Sep 2016 23:04:15 +0530 Subject: [PATCH] Also support '-h' as a default help flag --- README.md | 2 +- src/Commando/Command.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6d32b4b..1b502af 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Things to note: ## Baked in Help -Commando has automatic `--help` support built in. Calling your script with this flag will print out a pretty help page based on your option definitions and Commando settings. If you define an option with the alias of 'help', it will override this built in support. +Commando has automatic `--help` support built in. Calling your script with this flag (`-h` or `--help`) will print out a pretty help page based on your option definitions and Commando settings. If you define an option with the alias of 'help', it will override this built in support. ![help screenshot](http://cl.ly/image/1y3i2m2h220u/Screen%20Shot%202012-08-19%20at%208.54.49%20PM.png) diff --git a/src/Commando/Command.php b/src/Commando/Command.php index 3f1b92d..5595b0a 100755 --- a/src/Commando/Command.php +++ b/src/Commando/Command.php @@ -390,7 +390,9 @@ public function parse() $count++; } else { // Short circuit if the help flag was set and we're using default help - if ($this->use_default_help === true && $name === 'help') { + if ($this->use_default_help === true + && ($name === 'help' || $name === 'h') + ) { $this->printHelp(); exit; } @@ -693,7 +695,8 @@ public function printHelp() private function attachHelp() { // Add in a default help method - $this->option('help') + $this->option('h') + ->aka('help') ->describe('Show the help page for this command.') ->boolean(); }