#!/usr/bin/env php */ if (file_exists(__DIR__ . '/../../kronolith/lib/Application.php')) { $baseDir = __DIR__ . '/../'; } else { require_once 'PEAR/Config.php'; $baseDir = PEAR_Config::singleton() ->get('horde_dir', null, 'pear.horde.org') . '/kronolith/'; } require_once $baseDir . 'lib/Application.php'; Horde_Registry::appInit('kronolith', array('cli' => true)); // Read command line parameters. if (count($argv) != 3) { $cli->message('Too many or too few parameters.', 'cli.error'); usage(); } $cal = $argv[1]; $user = $argv[2]; // Read standard input. $ical = $cli->readStdin(); if (empty($ical)) { $cli->message('No import data provided.', 'cli.error'); usage(); } // Set user. $registry->setAuth($user, array()); // Import data. try { $result = $registry->call('calendar/import', array($ical, 'text/calendar', $cal)); } catch (Horde_Exception $e) { $cli->fatal($e->getMessage()); } $cli->message('Imported successfully ' . count($result) . ' events', 'cli.success'); function usage() { $GLOBALS['cli']->writeln('Usage: kronolith-import-icals calendar user'); exit; }