-
Notifications
You must be signed in to change notification settings - Fork 42
/
upx.go
65 lines (61 loc) · 1.36 KB
/
upx.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
package upx
import (
"fmt"
"runtime"
"time"
"github.com/urfave/cli"
)
const VERSION = "v0.4.8"
func CreateUpxApp() *cli.App {
app := cli.NewApp()
app.Name = "upx"
app.Usage = "a tool for driving UpYun Storage"
app.Author = "Hongbo.Mo"
app.Email = "[email protected]"
app.Version = fmt.Sprintf("%s %s/%s %s", VERSION,
runtime.GOOS, runtime.GOARCH, runtime.Version())
app.EnableBashCompletion = true
app.Compiled = time.Now()
app.Flags = []cli.Flag{
cli.BoolFlag{Name: "quiet, q", Usage: "not verbose"},
cli.StringFlag{Name: "auth", Usage: "auth string"},
}
app.Before = func(c *cli.Context) error {
if c.Bool("q") {
IsVerbose = false
}
if c.String("auth") != "" {
err := authStrToConfig(c.String("auth"))
if err != nil {
PrintErrorAndExit("%s: invalid auth string", c.Command.FullName())
}
}
return nil
}
app.Commands = []cli.Command{
NewLoginCommand(),
NewLogoutCommand(),
NewListSessionsCommand(),
NewSwitchSessionCommand(),
NewInfoCommand(),
NewCdCommand(),
NewPwdCommand(),
NewMkdirCommand(),
NewLsCommand(),
NewTreeCommand(),
NewGetCommand(),
NewPutCommand(),
NewUploadCommand(),
NewRmCommand(),
NewSyncCommand(),
NewAuthCommand(),
NewPostCommand(),
NewPurgeCommand(),
NewGetDBCommand(),
NewCleanDBCommand(),
NewUpgradeCommand(),
NewCopyCommand(),
NewMoveCommand(),
}
return app
}