throw new Exception($errstr, $errno); }); require_once __DIR__ . '/../autoload.php'; // consoleoptions $console = Console::getInstance(); $opt = (new Getopt(['projectId|p=s' => 'project id', 'accessToken|a=s' => 'user access token', 'localeDefault|l=s' => 'default locale. Default de-DE', 'applicationName|n-s' => 'name of your application. Default PHP PhraseApp Client', 'preferDirection|d-s' => 'prefer direction for sync (remote, local). Default: remote', 'exclude|x-s' => 'regex to exclude files. can be given multiple times: Default: []', 'tagForContentChangeFromLocalToRemote|t-s' => 'tag for content change from local to remote. Default: newContent', 'doNotUseLocaleDefaultAsLocaleSource|u' => 'do not use the default locale also as source locale.', 'help|h' => 'Display this help message', 'quiet|q' => 'Do not output any message', 'version|V' => 'Display this application version']))->setOptions([Getopt::CONFIG_CUMULATIVE_PARAMETERS => true]); try { $opt->parse(); if ($opt->help) { throw new \Exception('wants help'); } if (!$opt->version && count($opt->getRemainingArgs()) != 1) { throw new \Exception('missing remaining args'); } // create config $config = new Config($opt->projectId, $opt->accessToken, $opt->localeDefault); // set application name if ($opt->applicationName) { $config->setApplicationName($opt->applicationName); } // set preferDirection if ($opt->preferDirection) { $config->setPreferDirection($opt->preferDirection); } // set tagForContentChangeFromLocalToRemote if ($opt->tagForContentChangeFromLocalToRemote) { $config->setTagForContentChangeFromLocalToRemote($opt->tagForContentChangeFromLocalToRemote); } // set doNotUseLocaleDefaultAsLocaleSource if ($opt->doNotUseLocaleDefaultAsLocaleSource) { $config->setUseLocaleDefaultAsLocaleSource(false);
$message .= $console->colorize(' key delete <key>', ColorInterface::GREEN) . ' deletes the key.' . PHP_EOL; $message .= $console->colorize(' key list', ColorInterface::GREEN) . ' list the key.' . PHP_EOL; $message .= $console->colorize(' key update <key> <name> [description] [tag ...]', ColorInterface::GREEN) . ' updates the key.' . PHP_EOL; $message .= PHP_EOL; $message .= $console->colorize('translation Operations:', ColorInterface::YELLOW) . PHP_EOL; $message .= $console->colorize(' translation store <locale> <key> <content>', ColorInterface::GREEN) . ' set content of a key for a locale.' . PHP_EOL; try { $opt->parse(); if ($opt->help) { throw new \Exception('wants help'); } if (!$opt->version && count($opt->getRemainingArgs()) < 2) { throw new \Exception('missing remaining args'); } // create config $config = new Config($opt->projectId, $opt->accessToken, $opt->localeDefault); // set application name if ($opt->applicationName) { $config->setApplicationName($opt->applicationName); } } catch (\Exception $exception) { echo $opt->getUsageMessage($message); exit(1); } // version if ($opt->version) { $console->writeLine('PHP PhraseApp Client - ' . basename($_SERVER['argv'][0], '.php') . ' ' . (new Version())->get() . ' by Marco Starker'); exit(0); } try { if ((new Factory($config, $console))->factory($opt->getRemainingArgs())->execute() === false) {