add support for config file and multiple clusters config (#1)

This commit is contained in:
T. von Dein
2026-04-27 09:11:10 +02:00
parent 496f4aeda3
commit 17f92874e5
7 changed files with 154 additions and 37 deletions

View File

@@ -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
},
}