/**
  * @see	\wcf\system\cli\command\ICLICommand::execute()
  */
 public function execute(array $parameters)
 {
     $this->argv->setArguments($parameters);
     $this->argv->parse();
     $args = $this->argv->getRemainingArgs();
     if (count($args) != 1 || $args[0] != 'execute') {
         throw new ArgvException('', $this->getUsage());
     }
     CronjobScheduler::getInstance()->executeCronjobs();
 }
Example #2
0
 /**
  * @see	\wcf\system\cli\command\ICLICommand::execute()
  */
 public function execute(array $parameters)
 {
     $this->argv->setArguments($parameters);
     $this->argv->parse();
     $args = $this->argv->getRemainingArgs();
     // validate parameters
     if (count($args) != 1) {
         throw new ArgvException('', $this->getUsage());
     }
     $commands = CLICommandHandler::getCommands();
     if (!isset($commands[$args[0]])) {
         throw new ArgvException(CLIWCF::getLanguage()->getDynamicVariable('wcf.cli.error.command.notFound', array('command' => $args[0])), $this->getUsage());
     }
     $command = $commands[$args[0]];
     if (!$command instanceof IArgumentedCLICommand) {
         throw new ArgvException(CLIWCF::getLanguage()->getDynamicVariable('wcf.cli.error.help.noArguments', array('command' => $args[0])), $this->getUsage());
     }
     CLIWCF::getReader()->println($command->getUsage());
 }
 /**
  * Load the harvest settings. Return false on error.
  *
  * @return array|bool
  */
 protected function getSettings()
 {
     $ini = $this->opts->getOption('ini');
     $argv = $this->opts->getRemainingArgs();
     $section = isset($argv[0]) ? $argv[0] : false;
     if (!$ini && !$section) {
         $this->writeLine('Please specify an .ini file with the --ini flag' . ' or a target directory with the first parameter.');
         return false;
     }
     return $ini ? $this->getSettingsFromIni($ini, $section) : [$section => []];
 }
 /**
  * @see	\wcf\system\cli\command\ICLICommand::execute()
  */
 public function execute(array $parameters)
 {
     $this->argv->setArguments($parameters);
     $this->argv->parse();
     if (count($this->argv->getRemainingArgs()) !== 2) {
         throw new ArgvException('', $this->fixUsage($this->argv->getUsageMessage()));
     }
     list($action, $package) = $this->argv->getRemainingArgs();
     CLIWCF::getReader()->setHistoryEnabled(false);
     switch ($action) {
         case 'install':
             $this->install($package);
             break;
         case 'uninstall':
             $this->uninstall($package);
             break;
         default:
             throw new ArgvException('', $this->fixUsage($this->argv->getUsageMessage()));
             break;
     }
 }
Example #5
0
 $rules = array('help|h' => 'Get PHPoole usage message', 'init|i-s' => 'Build a new PHPoole website (<force>)', 'generate|g' => 'Generate static files', 'serve|s' => 'Start built-in web server', 'deploy|d' => 'Deploy static files', 'list|l' => 'Lists content');
 // Get and parse console options
 try {
     $opts = new Getopt($rules);
     $opts->parse();
 } catch (ConsoleException $e) {
     echo $e->getUsageMessage();
     exit(2);
 }
 // help option
 if ($opts->getOption('help') || count($opts->getOptions()) == 0) {
     echo $opts->getUsageMessage();
     exit(0);
 }
 // Get provided directory if exist
 if (!isset($opts->getRemainingArgs()[0])) {
     $path = '.';
 } else {
     $path = $opts->getRemainingArgs()[0];
 }
 if (!is_dir($path)) {
     $phpooleConsole->wlError('Invalid directory provided!');
     exit(2);
 }
 $websitePath = str_replace(DS, '/', realpath($path));
 // Instanciate the PHPoole API
 try {
     $phpoole = new PHPoole\PHPoole($websitePath);
 } catch (\Exception $e) {
     $phpooleConsole->wlError($e->getMessage());
     exit(2);
Example #6
0
    /**
     * @group ZF-5345
     */
    public function testUsingDashWithoutOptionNameAsLastArgumentIsRecognizedAsRemainingArgument()
    {
        $opts = new Getopt("abp:", array("-"));
        $opts->parse();

        $this->assertEquals(1, count($opts->getRemainingArgs()));
        $this->assertEquals(array("-"), $opts->getRemainingArgs());
    }
 /**
  * @see	\wcf\system\cli\command\ICLICommand::execute()
  */
 public function execute(array $parameters)
 {
     $this->argv->setArguments($parameters);
     $this->argv->parse();
     if ($this->argv->list) {
         CLIWCF::getReader()->println(CLIUtil::generateTable($this->generateList()));
         return;
     }
     $args = $this->argv->getRemainingArgs();
     // validate parameters
     if (count($args) != 1) {
         throw new ArgvException('', $this->getUsage());
     }
     $class = $args[0];
     // assume wcf\system\worker when no FQN is given
     if (strpos($class, '\\') === false) {
         $class = 'wcf\\system\\worker\\' . $class;
     }
     $invalid = false;
     if (!class_exists($class)) {
         $invalid = true;
     } else {
         $reflection = new \ReflectionClass($class);
         if (!$reflection->isInstantiable()) {
             $invalid = true;
         } else {
             if (!ClassUtil::isInstanceOf($class, 'wcf\\system\\worker\\IWorker')) {
                 $invalid = true;
             }
         }
     }
     if ($invalid) {
         throw new ArgvException("Invalid worker '" . $class . "' given", $this->getUsage());
     }
     // parse parameters
     $options = $this->argv->getOptions();
     $parameters = array();
     foreach ($options as $option) {
         $value = $this->argv->getOption($option);
         if ($option === 'setParameter') {
             if (!is_array($value)) {
                 $value = array($value);
             }
             foreach ($value as $parameter) {
                 list($parameterKey, $parameterValue) = explode('=', $parameter);
                 $parameters[$parameterKey] = $parameterValue;
             }
         } else {
             $parameters[$option] = $value;
         }
     }
     $worker = new $class($parameters);
     $worker->validate();
     $worker->getProgress();
     // make sure objects are counted
     // initialize progressbar
     $progressbar = new ProgressBar(new ConsoleProgressBar(array('width' => CLIWCF::getTerminal()->getWidth())));
     $progress = 0;
     for ($i = 0; $progress < 100; $i++) {
         $worker->setLoopCount($i);
         $worker->validate();
         // execute worker
         $worker->execute();
         // update progress
         $progress = $worker->getProgress();
         $progressbar->update($progress);
     }
     $progressbar->update($progress);
     $progressbar->getAdapter()->finish();
 }