-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.go
More file actions
55 lines (49 loc) · 985 Bytes
/
app.go
File metadata and controls
55 lines (49 loc) · 985 Bytes
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
package main
import (
"context"
"github.com/urfave/cli/v2"
)
const (
APP_NAME = "cles"
VERSION = "0.0.8"
REVISION = "HEAD"
)
func initializeContext(c *cli.Context) error {
fp, err := initDebugFunc(c.Bool("debug"))
if err != nil {
return err
}
//lint:ignore SA1029 initDebugFunc before subcommand
c.Context = context.WithValue(c.Context, "debugFunc", *fp)
err = setClient(c)
return err
}
func appRun(c *cli.Context) error {
args := c.Args()
if !args.Present() {
cli.ShowAppHelp(c)
}
return nil
}
func initApp() *cli.App {
app := cli.NewApp()
app.Name = APP_NAME
app.Usage = "Command line client for Elasticsearch"
app.Version = VERSION
app.Commands = commands
app.Action = appRun
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "profile",
Value: "default",
Aliases: []string{"p"},
Usage: "set profile name",
},
&cli.BoolFlag{
Name: "debug",
Usage: "show detail log",
},
}
app.Before = initializeContext
return app
}