diff --git a/README.md b/README.md index b61edb8..f7fe253 100644 --- a/README.md +++ b/README.md @@ -252,12 +252,6 @@ If the value is not specified, default to `$defaultValue`. In the case of `boolean()` type flags, when the flag is present, the value of this option the negation of `$defaultValue`. That is to say, if you have a flag -b with a default of `true`, when -b is present as a command line flag, the value of the option will be `false`. -### `file ()` - -Aliases: `expectsFile` - -The value specified for this option must be a valid file path. When used relative paths will be converted into fully quatified file paths and globbing is also optionally supported. See the file.php example. - ## Contributing Commando highly encourages sending in pull requests. When submitting a pull request please: diff --git a/src/Commando/Option.php b/src/Commando/Option.php index aad7def..e4c4912 100755 --- a/src/Commando/Option.php +++ b/src/Commando/Option.php @@ -285,7 +285,7 @@ public function parseFilePath($file_path) */ public function getName() { - return $this->name; + return ($this->title && is_numeric($this->name)) ? $this->title : $this->name; } /** diff --git a/tests/Commando/OptionTest.php b/tests/Commando/OptionTest.php index 9694d6b..3dda60d 100644 --- a/tests/Commando/OptionTest.php +++ b/tests/Commando/OptionTest.php @@ -29,7 +29,7 @@ public function testGetDescription() $this->assertEquals($description, $option->getDescription()); } - public function testAnnonymousOption() + public function testAnonymousOption() { $option = new Option(0); @@ -43,6 +43,15 @@ public function testAnnonymousOption() $this->assertEquals(1, $anon_option->getName()); } + public function testAnonymousOptionWithTitle() + { + $expected = 'test'; + $option = new Option(0); + $option->setTitle($expected); + + $this->assertEquals($expected, $option->getName()); + } + public function testAddAlias() { $name = 'f';