-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
74 lines (63 loc) · 1.47 KB
/
main.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
71
72
73
74
package main
import (
"fmt"
"os"
"github.com/BlacksunLabs/thymeline/database"
"github.com/BlacksunLabs/thymeline/screenshot"
"github.com/BlacksunLabs/thymeline/ui"
flag "github.com/spf13/pflag"
)
// Commandline flags
var (
newopFlag bool
)
// Parse commandline options
func init() {
flag.BoolVarP(&newopFlag, "new", "n", false, "used to create and monitor a new operation directory")
flag.Parse()
}
func createop() {
dir, err := ui.ChooseDirectory()
if err != nil {
fmt.Printf("cannot access directory %s : %v", dir, err)
return
}
opName, ok, err := ui.GetText("Name of operation")
if err != nil {
fmt.Printf("%v", err)
return
} else if !ok {
fmt.Println("user clicked cancel.. Skipping adding operation directory to monitor")
return
}
s, err := db.Connect()
if err != nil {
fmt.Printf("unable to connect to database: %v", err)
return
}
defer s.Close()
opdir := db.OpDir{
Operation: db.Op{
Name: opName,
Path: dir,
},
}
err = opdir.AddToDB(*s)
if err != nil {
fmt.Printf("unable to add operation to database: %v", err)
}
// [BUG]: Not sure why but the Directory Chooser dialog box remains open
// after following a successful code path and causes the entire program to
// deadlock.
//
// Using os.Exit(0) as a hacky alternative to a typical return in order to
// mitigate this issue until a solution can be found.
os.Exit(0)
}
func main() {
// Handle commandline options
if newopFlag {
createop()
}
screenshot.WatchDirs()
}