/** * Formats time. * * @param integer $timestamp * @return string */ public static function formatTime($timestamp) { $dateTimeObject = DateUtil::getDateTimeByTimestamp($timestamp); $date = DateUtil::format($dateTimeObject, DateUtil::DATE_FORMAT); $time = DateUtil::format($dateTimeObject, DateUtil::TIME_FORMAT); return str_replace('%time%', $time, str_replace('%date%', $date, CLIWCF::getLanguage()->get('wcf.date.dateTimeFormat'))); }
/** * @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()); }
/** * Displays an error message. * * @param string $name * @param array $parameters */ public function error($name, array $parameters = array()) { Log::error('package.' . $name . ':' . JSON::encode($parameters)); if ($parameters) { throw new ArgvException(CLIWCF::getLanguage()->getDynamicVariable('wcf.acp.package.error.' . $name, $parameters), $this->getUsage()); } else { throw new ArgvException(CLIWCF::getLanguage()->get('wcf.acp.package.error.' . $name), $this->argv->getUsageMessage()); } }
/** * Initializes the argument parser. */ public function __construct() { $this->argv = new ArgvParser(array('l|list' => CLIWCF::getLanguage()->get('wcf.cli.worker.list'), 'setParameter=s' => CLIWCF::getLanguage()->get('wcf.cli.worker.setParameter'))); $this->argv->setOptions(array(ArgvParser::CONFIG_FREEFORM_FLAGS => true, ArgvParser::CONFIG_PARSEALL => false, ArgvParser::CONFIG_CUMULATIVE_PARAMETERS => true)); }