-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
31 lines (24 loc) · 1.06 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
use League\Csv\Reader;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
use WizOneSolutions\TwoDoToTodoist\Todoist\Importer;
use WizOneSolutions\TwoDoToTodoist\TwoDo\CSVConverter;
require_once(__DIR__ . '/vendor/autoload.php');
if (empty($GLOBALS['argv'][1])) {
die("Usage: php index.php <FILE PATH>");
}
// Load config from YAML. Determine if this is a dry run or not.
try {
$config = Yaml::parse(file_get_contents(__DIR__ . '/config.yml'));
if (empty($config['api_token'])) {
die("You need to configure your api_token before running this importer. See config-example.yml in the same directory as this script and copy it to config.yml.");
}
$reader = Reader::createFromPath($GLOBALS['argv'][1]);
$tasks = CSVConverter::parse($reader, $config);
Importer::import($tasks, $config);
} catch (ParseException $exception) {
die('Unable to parse the YAML string: ' . $exception->getMessage());
} catch (\Exception $exception) {
die('Unexpected exception encountered: ' . $exception->getMessage());
}