mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 08:04:17 +02:00
add support for config file and multiple clusters config (#1)
This commit is contained in:
25
cmd/root.go
25
cmd/root.go
@@ -37,10 +37,7 @@ func Finish(err error) int {
|
||||
}
|
||||
|
||||
func Main() int {
|
||||
conf, err := cfg.Init()
|
||||
if err != nil {
|
||||
return Finish(err)
|
||||
}
|
||||
conf := cfg.NewConfig()
|
||||
|
||||
cmd := &cli.Command{
|
||||
Name: "esctl",
|
||||
@@ -57,6 +54,21 @@ func Main() int {
|
||||
Sources: cli.EnvVars("ES_DEBUG"),
|
||||
Destination: &conf.Debug,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "config",
|
||||
Aliases: []string{"c"},
|
||||
Value: "",
|
||||
Usage: "config file",
|
||||
Sources: cli.EnvVars("ES_CONFIG"),
|
||||
Destination: &conf.ConfigFile,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "cluster",
|
||||
Aliases: []string{"C"},
|
||||
Value: "",
|
||||
Usage: "cluster alias to work with",
|
||||
Destination: &conf.CurrentCluster,
|
||||
},
|
||||
},
|
||||
|
||||
Commands: []*cli.Command{
|
||||
@@ -67,7 +79,12 @@ func Main() int {
|
||||
},
|
||||
|
||||
Before: func(ctx context.Context, cmd *cli.Command) (context.Context, error) {
|
||||
if err := conf.Init(); err != nil {
|
||||
Finish(err)
|
||||
}
|
||||
|
||||
log.Init(conf)
|
||||
|
||||
return nil, nil
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user