-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandLineActions.fs
38 lines (28 loc) · 940 Bytes
/
CommandLineActions.fs
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
module CommandLineActions
open WunderlistBackup
open Actions
let commandLinePick () =
CommandLine.pick [ Sync; View ]
(fun ba -> match ba with
| Sync -> "Start new backup"
| View -> "View backups")
let asyncBackup credentials =
credentials |>
Wunderlist.getAllData
let asyncSaveToDatabase credentials =
async {
let! backup = asyncBackup credentials
do! Save.saveToDb backup
}
let queryUserForAction commandLinePick mapActionTypeToAction () =
let actionTypeOption = commandLinePick()
let action =
match actionTypeOption with
| None -> None
| Some actionType -> Some (mapActionTypeToAction actionType)
action
let run queryUserForAction =
let userSelection = queryUserForAction()
match userSelection with
| None -> Failure
| Some action -> action()