Improvements to the CLI.
This commit is contained in:
@@ -162,7 +162,8 @@ EOT;
|
|||||||
while ($taskName{0} == '-')
|
while ($taskName{0} == '-')
|
||||||
$taskName = array_shift($args);
|
$taskName = array_shift($args);
|
||||||
if (!$taskName) {
|
if (!$taskName) {
|
||||||
self::help();
|
echo self::error("Specify a task from the list below.") . "\n\n";
|
||||||
|
self::help(NULL, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$taskData = NULL;
|
$taskData = NULL;
|
||||||
@@ -172,12 +173,20 @@ EOT;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!$taskData) {
|
||||||
|
echo self::error("Command not found: '$taskName'") . "\n\n";
|
||||||
|
self::help(NULL, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
G::LoadThirdParty('pear/Console', 'Getopt');
|
G::LoadThirdParty('pear/Console', 'Getopt');
|
||||||
$short = "h" . $taskData['opt']['short'];
|
$short = "h" . $taskData['opt']['short'];
|
||||||
$long = array_merge(array("help"), $taskData['opt']['long']);
|
$long = array_merge(array("help"), $taskData['opt']['long']);
|
||||||
list($options, $arguments) = Console_GetOpt::getopt2($args, $short, $long);
|
list($options, $arguments) = Console_GetOpt::getopt2($args, $short, $long);
|
||||||
|
try {
|
||||||
call_user_func($taskData['function'], $arguments, $options);
|
call_user_func($taskData['function'], $arguments, $options);
|
||||||
die();
|
} catch (Exception $e) {
|
||||||
|
echo self::error("\n Error executing '$taskName':\n\n {$e->getMessage()}\n") . "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user