-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (45 loc) · 869 Bytes
/
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
package main
import (
"flag"
"path/filepath"
"github.com/das6ng/workman/mgr"
)
var (
fNoCUI bool
fList bool
fUpdate string
)
var out mgr.Printer
func main() {
flag.BoolVar(&fNoCUI, "n", false, "no command line ui")
flag.BoolVar(&fList, "l", false, "list go.work info")
flag.StringVar(&fUpdate, "u", "{}", "update go.work")
flag.Parse()
out.SetOutput(func() mgr.Output {
if fNoCUI {
return mgr.OutputJSON
}
return mgr.OutputCUI
}())
cur, _ := filepath.Abs(".")
mgr := &mgr.WorkManager{Printer: out}
if err := mgr.Load(cur); err != nil {
out.Msg("cannot load workspace", err)
return
}
// command line ui mode
if !fNoCUI {
mgr.CUIMain()
return
}
// arg mode
if fList {
out.Print(mgr.GetInfo())
return
}
if fUpdate != "{}" && fUpdate != "" {
out.Print(mgr.ArgUpdate(fUpdate))
return
}
out.Msg("nothing to do")
}