public function run($argc, array $argv)
{
$errs = [];
$prog = array_shift($argv);
foreach ($this->args->parse(--$argc, $argv) as $error) {
$errs[] = $error;
}
if ($this->args["help"]) {
$this->header();
$this->help($prog);
exit;
}
try {
foreach (["signature", "license", "version"] as $opt) {
if ($this->args[$opt]) {
printf("%s\n", $this->metadata($opt));
exit;
}
}
} catch (\Exception $e) {
$this->error("%s\n", $e->getMessage());
exit(self::EARGS);
}
try {
/* source needs to be evaluated before Cli\Args validation,
* so Cli\Args does not complain about missing arguments,
* which come from SourceDir::getPackageInfo()
*/
$this->loadSource();
} catch (\Exception $e) {
$errs[] = $e->getMessage();
}
foreach ($this->args->validate() as $error) {
$errs[] = $error;
}
if ($errs) {
if (!$this->args["quiet"]) {
$this->header();
}
foreach ($errs as $err) {
$this->error("%s\n", $err);
}
printf("\n");
if (!$this->args["quiet"]) {
$this->help($prog);
}
exit(self::EARGS);
}
$this->createPackage();
}