-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.go
79 lines (71 loc) · 1.73 KB
/
setup.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
75
76
77
78
79
package main
import (
"errors"
"fmt"
"github.com/urfave/cli/v2"
)
func teardown(c *cli.Context) error {
if c.NArg() != 1 && c.NArg() != 2 {
return errors.New("only have 1 or 2 arguments, either 'bash', 'zsh', 'powershell $PROFILE")
}
t := c.Args().Get(0)
if t == "bash" {
if c.NArg() != 1 {
return errors.New("'teardown bash' has no other arguments")
}
return tearDownBash()
} else if t == "zsh" {
if c.NArg() != 1 {
return errors.New("'teardown zsh' has no other arguments")
}
return tearDownZsh()
} else if t == "powershell" {
if c.NArg() != 2 {
return errors.New("'teardown zsh $profile' has no other arguments")
}
profile := c.Args().Get(1)
return tearDownPowerShell(profile)
} else {
return errors.New("only have 1 argument, either 'bash' or 'zsh'")
}
}
func setup(c *cli.Context) error {
if c.NArg() != 1 && c.NArg() != 2 {
return e1("only have 1 or 2 arguments, either 'bash', 'zsh', 'powershell $PROFILE")
}
t := c.Args().Get(0)
if t == "bash" {
if c.NArg() != 1 {
return e1("'setup bash' has no other arguments")
}
return setupBash()
} else if t == "zsh" {
if c.NArg() != 1 {
return e1("'setup zsh' has no other arguments")
}
return setupZSH()
} else if t == "powershell" {
if c.NArg() != 2 {
return e1("'setup zsh $profile' has no other arguments")
}
profile := c.Args().Get(1)
return setupPowerShell(profile)
} else {
return e1("only have 1 argument, either 'bash' or 'zsh'")
}
}
func teardownComplete(c *cli.Context) {
if c.NArg() == 0 {
fmt.Println("bash")
fmt.Println("zsh")
fmt.Println("powershell")
} else if c.NArg() == 1 {
if c.Args().Get(0) == "powershell" {
fmt.Println("$profile")
} else {
fmt.Println("")
}
} else {
fmt.Println("")
}
}