-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
45 lines (34 loc) · 1.34 KB
/
Program.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.IO;
using System.Threading;
namespace ExistSpoon
{
public class Program
{
private const string ClientId = "c9aa845538a191f78b06";
private const string ClientSecret = "48c23e11279ee02ada0544c15b137693b8cde93d";
private const string RedirectUri = "http://127.0.0.1:5555/";
public static int Main(string[] args)
{
ProgressAggregator.Published += OnProgress;
if (args.Length == 0 || !File.Exists(args[0]))
{
ProgressAggregator.Publish("First argument must be path to .TDL task list.");
return -1;
}
var tdlPath = args[0];
ProgressAggregator.Publish($"Submitting completed task count from {tdlPath}");
var authenticator = new OpenAuthenticator(ClientId, ClientSecret, RedirectUri);
string oauthToken = authenticator.Authenticate();
var completions = new TdlFile(tdlPath).PerseCompletions();
new ExistClient(oauthToken).SubmitCompletions(completions);
while (authenticator.FlushingProgress)
Thread.Sleep(10);
return 0;
}
private static void OnProgress(string message)
{
Console.WriteLine(message);
}
}
}