nategood / commando

An Elegant CLI Library for PHP
MIT License
798 stars 80 forks source link

Hyphenated names fail #25

Closed adamaveray closed 10 years ago

adamaveray commented 10 years ago

If you have an option/flag with a hyphen in the middle of its name, Commando accepts it but only parses the received argument's name up to the hyphen.

Example:

<?php
$cmd = new Commando\Command();

$cmd->option('basicarg');
$cmd->option('hyphen-arg');

var_dump($cmd['basicarg']);
var_dump($cmd['hyphen-arg']);

Calls:

$ php script.php --basicarg hello
string(5) "hello"
NULL

$ php script.php --hyphen-arg hello
ERROR: Unknown option, hyphen, specified 
mackenza commented 10 years ago

it was the regex on the _parseOption method which was accepting underscores but not -. @nategood I didn't see a test to alter. I suppose I could write one to check just this. What do you think?

nategood commented 10 years ago

26