-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
81 lines (74 loc) · 1.78 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
package main
import (
"os"
"strconv"
"github.com/gookit/color"
"github.com/urfave/cli/v2"
"ui/cli/commands"
)
func main() {
app := &cli.App{
Name: "UI-CLI",
HelpName: "ui",
Usage: "Simple tool for installing deb package for LInux Distributions.",
Version: "v0.7.4",
Commands: []*cli.Command{
{
Name: "version",
Aliases: []string{"v"},
Usage: "show the version of ui",
Action: commands.Version,
},
{
Name: "install",
Aliases: []string{"i"},
Usage: "install or update packages",
Description: "If no package name is specified, it will install all packages in configured source.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
Usage: "name of the file to install",
},
},
Action: commands.Install,
},
{
Name: "source",
Aliases: []string{"s"},
Usage: "manage source of package",
Description: "If no options are specified, it will list all sources of package on local machine.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
Usage: "package name of the source",
},
&cli.StringFlag{
Name: "url",
Aliases: []string{"u"},
Usage: "url of the source",
},
},
Action: commands.Source,
},
{
Name: "update-self",
Aliases: []string{"us"},
Usage: "update ui-cli to the latest version",
Action: func(ctx *cli.Context) error {
commands.UpdateSelf(ctx)
return nil
},
},
},
}
if err := app.Run(os.Args); err != nil {
var errorString = err.Error()
if errorNumber, err := strconv.Atoi(errorString); err == nil {
os.Exit(errorNumber)
}
color.Redln(errorString)
os.Exit(1)
}
}