$all_commands = PEAR_Command::getCommands();
$argv = Console_Getopt::readPHPArgv();
-$progname = basename($argv[0]);
-array_shift($argv);
-$options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV");
+/* $progname = basename($argv[0]); */
+$progname = 'pear';
+if (in_array('getopt2', get_class_methods('Console_Getopt'))) {
+ array_shift($argv);
+ $options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV");
+} else {
+ $options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:vV");
+}
if (PEAR::isError($options)) {
usage($options);
}
$short_args = $long_args = null;
PEAR_Command::getGetoptArgs($command, $short_args, $long_args);
- array_shift($options[1]);
- if (PEAR::isError($tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args))) {
+ if (in_array('getopt2', get_class_methods('Console_Getopt'))) {
+ array_shift($options[1]);
+ $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args);
+ } else {
+ $tmp = Console_Getopt::getopt($options[1], $short_args, $long_args);
+ }
+ if (PEAR::isError($tmp)) {
break;
}
list($tmpopt, $params) = $tmp;
return "$progname $command [options] $help[0]\n$help[1]";
}
}
- return "No such command";
+ return "Command '$command' is not valid, try 'pear help'";
}
// }}}