-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
88 lines (82 loc) · 1.62 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
package main
import (
"fmt"
"github.com/urfave/cli/v2"
"log"
"os"
)
func main() {
var tagName string
cmds := []*cli.Command{
{
Name: "install",
Aliases: []string{"i"},
Usage: "Install qBittorrent",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "tag",
Aliases: []string{"t"},
Usage: "set qBittorrent tag name",
Destination: &tagName,
},
},
Action: func(ctx *cli.Context) (err error) {
err = installBinaryFile(tagName)
if err != nil {
return err
}
return installService()
},
},
{
Name: "uninstall",
Usage: "Remove config,cache and uninstall qBittorrent",
Action: func(ctx *cli.Context) (err error) {
err = uninstallService()
if err != nil {
return err
}
return uninstallBinaryFile()
},
},
{
Name: "update",
Usage: "Update qBittorrent",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "tag",
Aliases: []string{"t"},
Usage: "set qBittorrent tag name",
Destination: &tagName,
},
},
Action: func(ctx *cli.Context) (err error) {
err = updateBinaryFile(tagName)
if err != nil {
return err
}
return updateService()
},
},
{
Name: "reload",
Usage: "Reload service",
Action: func(ctx *cli.Context) (err error) {
return reloadService()
},
},
}
// 打印版本函数
cli.VersionPrinter = func(cCtx *cli.Context) {
fmt.Printf("%s", cCtx.App.Version)
}
app := &cli.App{
Usage: "qBittorrent quick install tool",
Version: "v2.01",
Commands: cmds,
}
err := app.Run(os.Args)
if err != nil {
log.Fatalln(err)
}
}