This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
158 lines (153 loc) · 3.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package main
import (
"fmt"
"os"
"github.com/urfave/cli/v2"
"gitlab.com/bjerke-tek/gov/constants"
"gitlab.com/bjerke-tek/gov/controllers"
)
func main() {
app := &cli.App{
Name: constants.Name,
Usage: fmt.Sprintf("version: %s", constants.Version),
UsageText: "gov [command] [value_if_needed]",
Commands: []*cli.Command{
{
Name: "list-supported",
Aliases: []string{"s"},
Usage: "List available supported Go versions",
Action: func(c *cli.Context) error {
controllers.ListSupportedVersions()
return nil
},
},
{
Name: "list-all",
Aliases: []string{"a"},
Usage: "List all available Go versions",
Action: func(c *cli.Context) error {
controllers.ListAllVersions()
return nil
},
},
{},
{
Name: "install",
Aliases: []string{"i"},
Usage: "Install a Go version or use the 'latest' tag",
Action: func(c *cli.Context) error {
if c.NArg() == 1 {
controllers.InstallGoVersion(c.Args().First())
} else {
fmt.Println("Please provide a Go version to install.")
}
return nil
},
},
{
Name: "reinstall",
Aliases: []string{"r"},
Usage: "Reinstall a Go version",
Action: func(c *cli.Context) error {
if c.NArg() == 1 {
controllers.ReinstallGoVersion(c.Args().First())
} else {
fmt.Println("Please provide a Go version to reinstall.")
}
return nil
},
},
{
Name: "use",
Aliases: []string{"u"},
Usage: "Use a specific Go version",
Action: func(c *cli.Context) error {
if c.NArg() == 1 {
controllers.UseGoVersion(c.Args().First())
} else {
fmt.Println("Please provide a Go version to use.")
}
return nil
},
},
{},
{
Name: "current",
Aliases: []string{"c"},
Usage: "Display the currently used Go version",
Action: func(c *cli.Context) error {
controllers.DisplayCurrentVersion()
return nil
},
},
{
Name: "list",
Aliases: []string{"l"},
Usage: "List installed Go versions",
Action: func(c *cli.Context) error {
controllers.ListInstalledVersions()
return nil
},
},
{},
{
Name: "remove",
Aliases: []string{"x"},
Usage: "Remove a Go version",
Action: func(c *cli.Context) error {
if c.NArg() == 1 {
controllers.RemoveGoVersion(c.Args().First())
} else {
fmt.Println("Please provide a Go version to remove.")
}
return nil
},
},
{
Name: "prune",
Aliases: []string{"p"},
Usage: "Remove all Go versions except the currently used one",
Action: func(c *cli.Context) error {
controllers.Prune()
return nil
},
},
{},
{
Name: "version",
Aliases: []string{"v"},
Usage: "Show the installed version of gov",
Action: func(c *cli.Context) error {
controllers.GovVersion()
return nil
},
},
{
Name: "self-update",
Aliases: []string{"e"},
Usage: "Update gov to the latest version",
Action: func(c *cli.Context) error {
controllers.SelfUpdate()
return nil
},
},
{
Name: "sayonara",
Usage: "Uninstall gov from your system",
Action: func(c *cli.Context) error {
controllers.Sayonara()
return nil
},
},
{},
},
}
err := app.Run(os.Args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Requieres rework
// controllers.CheckForGovUpdates()
// controllers.CheckForGoUpdates()
}