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);
}
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);
}
foreach ($this->args[0] as $file) {
$info = new SplFileInfo($file);
while ($info->isLink()) {
$info = new SplFileInfo($info->getLinkTarget());
}
if ($info->isFile()) {
if (!$this->updatePackage($info)) {
$this->warn("Cannot upgrade pre-v3 packages\n");
}
} else {
$this->error("File '%s' does not exist\n", $file);
exit(self::EARGS);
}
}
}