+$cfgFile = __DIR__ . '/data/surrogator.config.php';
+if (!file_exists($cfgFile)) {
+ $cfgFile = '/etc/surrogator.config.php';
+ if (!file_exists($cfgFile)) {
+ logErr(
+ "Configuration file does not exist.\n"
+ . "Copy data/surrogator.config.php.dist to data/surrogator.config.php"
+ );
+ exit(2);
+ }
+}
+require $cfgFile;
+
+array_shift($argv);
+$files = array();
+foreach ($argv as $arg) {
+ if ($arg == '-v' || $arg == '--verbose') {
+ ++$logLevel;
+ } else if ($arg == '-vv') {
+ $logLevel += 2;
+ } else if ($arg == '-q' || $arg == '--quiet') {
+ $logLevel = 0;
+ } else if ($arg == '-f' || $arg == '--force') {
+ $forceUpdate = true;
+ } else if ($arg == '-h' || $arg == '--help') {
+ showHelp();
+ exit(4);
+ } else if ($arg == '--version') {
+ echo "surrogator 0.0.1\n";
+ exit();
+ } else if (file_exists($arg)) {
+ $files[] = $arg;
+ } else {
+ logErr('Unknown argument: ' . $arg);
+ exit(3);
+ }
+}
+
+/**
+ * Echos the --help screen.
+ *
+ * @return void
+ */
+function showHelp()
+{
+ echo <<<HLP
+Usage: php surrogator.php [options] [filename(s)]
+
+surrogator - a simple libravatar server
+ Put files in raw/ dir and run surrogator.php to generate different sizes
+
+Options:
+
+ -h, --help Show help
+ -v, --verbose Be verbose (more log messages, also -vv)
+ -q, --quiet Be quiet (no log messages)
+ -f, --force Force update of all files
+ --version Show program version
+
+filenames One or several files whose small images shall get generated.
+ If none given, all will be checked
+
+HLP;
+}