Re: Re: Console_Getopt and 'ambiguous' options
| From: | bertrand Gugger | Date: | Mon, 07 Nov 2005 11:51:24 +0000 |
| Subject: | Re: Re: Console_Getopt and 'ambiguous' options | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21825@lists.php.net to get a copy of this message | ||
Bonjour,
Jocke Selin wrote:
Bertrand, thanks for your reply - however you've confused me even more :) I'm a specialist of it :(Demo better, testGetopt.php: <?php error_reporting(E_ALL); require_once 'Console/Getopt.php'; $options = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'ab:c::',
array('type_id=', 'type_name=', 'type_process==',
'thing_id=', 'thing_name=', 'address==', 'switch'));
if (PEAR::isError($options)) {
die($options->getMessage() . "\n");
}
var_dump($options);
?>
[bertrand@ancilla test]$ php -q testGetopt.php --type_id=12 --type_name=Stuff --type_process=complete blah
array(2) {
[0]=>
array(3) {
[0]=>
array(2) {
[0]=>
string(9) "--type_id"
[1]=>
string(2) "12"
}
[1]=>
array(2) {
[0]=>
string(11) "--type_name"
[1]=>
string(5) "Stuff"
}
[2]=>
array(2) {
[0]=>
string(14) "--type_process"
[1]=>
string(8) "complete"
}
}
[1]=>
array(1) {
[0]=>
string(4) "blah"
}
}
[bertrand@ancilla test]$ php -q testGetopt.php --type_id=12 --type_name=Stuff --type_p=complete blah
array(2) {
[0]=>
array(3) {
[0]=>
array(2) {
[0]=>
string(9) "--type_id"
[1]=>
string(2) "12"
}
[1]=>
array(2) {
[0]=>
string(11) "--type_name"
[1]=>
string(5) "Stuff"
}
[2]=>
array(2) {
[0]=>
string(8) "--type_p"
[1]=>
string(8) "complete"
}
}
[1]=>
array(1) {
[0]=>
string(4) "blah"
}
}
[bertrand@ancilla test]$ php -q testGetopt.php --type_id=12 --type_name=Stuff --type_=complete blah
Console_Getopt: option --type_ is ambiguous
As you see, so long I say "type_process" or at least "type_p", the last option is seen right.
But if I say "type_" only, then Getopt cannot find out which option it is.
a+
--
bertrand "toggg" Gugger