protected function setArgumentHandlers() { return parent::setArgumentHandlers()->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) === 0) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->setReportFormat(current($values)); }, array('-fmt', '--format'), '<xml|clover|html|treemap>', $this->locale->_('Coverage report format'))->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) === 0) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->setReportOutputPath(current($values)); }, array('-o', '--output'), '<path/to/file/or/directory>', $this->locale->_('Coverage report output path')); }
protected function setArgumentHandlers() { return parent::setArgumentHandlers()->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) !== 0) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->infos(); }, array('-i', '--infos'), null, $this->locale->_('Display informations, do not run any script'))->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) !== 0) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->signature(); }, array('-s', '--signature'), null, $this->locale->_('Display phar signature, do not run any script'))->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) !== 1) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->extractTo($values[0]); }, array('-e', '--extract-to'), '<directory>', $this->locale->_('Extract all file from phar to <directory>, do not run any script'))->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) !== 1) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->extractResourcesTo($values[0]); }, array('-er', '--extract-resources-to'), '<directory>', $this->locale->_('Extract resources from phar to <directory>, do not run any script'))->addArgumentHandler(function ($script, $argument, $values, $position) { if ($position !== 1 || sizeof($values) !== 1) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } unset($_SERVER['argv'][1]); unset($_SERVER['argv'][2]); $script->useScript($values[0]); }, array('-u', '--use'), '<script> <args>', $this->locale->_('Run script <script> from PHAR with <args> as arguments (this argument must be the first)'), 4)->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) > 0) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->listScripts(); }, array('-ls', '--list-scripts'), null, $this->locale->_('List available scripts'))->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) > 0) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->update(); }, array('--update'), null, $this->locale->_('Update atoum'))->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) > 0) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->listAvailableVersions(); }, array('-lav', '--list-available-versions'), null, $this->locale->_('List available versions in the PHAR'))->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) != 1) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->enableVersion($values[0]); }, array('-ev', '--enable-version'), '<version>', $this->locale->_('Enable version <version>'))->addArgumentHandler(function ($script, $argument, $values) { if (sizeof($values) != 1) { throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName())); } $script->deleteVersion($values[0]); }, array('-dv', '--delete-version'), '<version>', $this->locale->_('Delete version <version>')); return $this; }