public function parseArguments()
{
// Add the list of options to the OptionParser
foreach ($this->availableOptions as $name => $desc) {
$desc[3] = isset($desc[3]) ? $desc[3] : null;
list($longName, $shortName, $description, $argumentName) = $desc;
$this->optionParser->addOption($name, $longName, $shortName, $description, $argumentName);
}
// Parse the arguments, assign the options
$this->optionParser->parseArguments($this->arguments);
$this->options = $this->optionParser->getOptions();
// Verify the paths, listing any invalid paths
$paths = $this->optionParser->getPaths();
if ($paths) {
$this->paths = $paths;
foreach ($this->paths as $path) {
if (!file_exists($path)) {
$this->exitStatus = 1;
$this->writeLn("The file or path \"{$path}\" doesn't exist");
}
}
}
// Render help or version text if necessary, and display errors
if ($this->options['help']) {
$this->exitStatus = 0;
$this->printHelp();
} elseif ($this->options['version']) {
$this->exitStatus = 0;
$this->printVersion();
} elseif ($this->optionParser->getInvalidArguments()) {
$this->exitStatus = 1;
foreach ($this->optionParser->getInvalidArguments() as $invalidArg) {
$this->writeLn("{$invalidArg} is not a valid option");
}
}
}