-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (58 loc) · 1.19 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
/*
apto is a command line tool automatically generated by ´gobi´. Happy hacking!
*/
package main
import (
"flag"
"log"
"os"
"github.com/fern4lvarez/apto/apto"
)
func main() {
force := flag.Bool("f", false, "force command (only available for uninstall)")
flag.Parse()
if l := len(flag.Args()); l == 0 {
log.Println("Hello apto")
return
} else {
switch first := flag.Args()[0]; first {
case "install":
err := apto.Install(flag.Args())
if err != nil {
log.Println(err)
os.Exit(1)
}
case "uninstall":
args, force_ := apto.HandleFlag(flag.Args(), "-f")
err := apto.Uninstall(args, *force || force_)
if err != nil {
log.Println(err)
os.Exit(1)
}
case "update":
if len(flag.Args()) > 1 {
log.Println("No parameters accepted for update command")
os.Exit(1)
}
err := apto.Update()
if err != nil {
log.Println(err)
os.Exit(1)
}
case "upgrade":
if len(flag.Args()) > 1 {
log.Println("No parameters accepted for upgrade command")
os.Exit(1)
}
err := apto.Upgrade()
if err != nil {
log.Println(err)
os.Exit(1)
}
case "file":
apto.File(flag.Args())
default:
log.Println("Hello", first)
}
}
}