mageekguy\atoum\script::setArgumentHandlers PHP Method

setArgumentHandlers() protected method

protected setArgumentHandlers ( )
    protected function setArgumentHandlers()
    {
        $this->argumentsParser->resetHandlers();
        $this->help = array();
        return $this;
    }

Usage Example

 protected function setArgumentHandlers()
 {
     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->help();
     }, array('-h', '--help'), null, $this->locale->_('Display this help'))->addArgumentHandler(function ($script, $argument, $files) {
         if (sizeof($files) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         foreach ($files as $path) {
             try {
                 $script->useConfigFile($path);
             } catch (includer\exception $exception) {
                 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Configuration file \'%s\' does not exist'), $path));
             }
         }
     }, array('-c', '--configurations'), '<file>...', $this->locale->_('Use all configuration files <file>'), PHP_INT_MAX);
     return $this;
 }
All Usage Examples Of mageekguy\atoum\script::setArgumentHandlers