feat: add server-config command (#346)
* feat: added server-config command * chore: update openapi to latest
This commit is contained in:
@ -57,6 +57,7 @@ var app = cli.App{
|
||||
newTemplateCmd(),
|
||||
newRemoteCmd(),
|
||||
newReplicationCmd(),
|
||||
newServerConfigCommand(),
|
||||
},
|
||||
Before: middleware.WithBeforeFns(withContext(), middleware.NoArgs),
|
||||
}
|
||||
|
43
cmd/influx/server_config.go
Normal file
43
cmd/influx/server_config.go
Normal file
@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/influxdata/influx-cli/v2/clients/server_config"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func newServerConfigCommand() cli.Command {
|
||||
var params server_config.ListParams
|
||||
return cli.Command{
|
||||
Name: "server-config",
|
||||
Usage: "Display server config",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.BoolFlag{
|
||||
Name: "toml",
|
||||
Usage: "Output configuration as TOML instead of JSON",
|
||||
Destination: ¶ms.TOML,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "yaml",
|
||||
Usage: "Output configuration as YAML instead of JSON",
|
||||
Destination: ¶ms.YAML,
|
||||
},
|
||||
),
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
if params.TOML && params.YAML {
|
||||
return errors.New("cannot specify both TOML and YAML simultaneously")
|
||||
}
|
||||
|
||||
api := getAPI(ctx)
|
||||
client := server_config.Client{
|
||||
CLI: getCLI(ctx),
|
||||
ConfigApi: api.ConfigApi,
|
||||
}
|
||||
return client.List(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user