-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtodoista.go
70 lines (54 loc) · 1.08 KB
/
todoista.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// The todoista program a CLI UI for working with todoist.
package main
import (
"github.com/cyberdummy/todoista/todoist"
)
type todoista struct {
todoist *todoist.Todoist
msgs []message
hist []hRecord
cfg config
ui userInterface
}
var app todoista
func main() {
var err error
// Read in config from various sources
getConfig()
app.todoist, err = todoist.New(app.cfg.apiKey)
if err != nil {
panic("Unable to create new todoist")
}
// Creates the UI app, sets up the binds
uiInit()
messagesInit()
historyInit()
showScreen(projects)
doSync()
uiRun()
messagesShutdown()
}
func setUIMessage(message string) {
app.ui.msg.SetText(message)
app.ui.app.Draw()
}
func doSync() {
var err error
setUIMessage("Syncing...")
app.todoist, err = app.todoist.ReadSync()
if err != nil {
setUIMessage("Sync failed! [red]" + err.Error())
addMessage(message{message: err.Error(), isError: true})
return
}
switch app.ui.screen {
case projects:
buildProjectIdx()
break
case items:
buildItemIdx()
break
}
setUIMessage("Sync Complete")
app.ui.app.Draw()
}