
Display an error when the OrgName and OrgId flags are both passed in. Only one or the other is allowed. closes https://github.com/influxdata/influx-cli/issues/371
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/influxdata/influx-cli/v2/clients/dashboards"
|
|
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
func newDashboardsCommand() cli.Command {
|
|
var params dashboards.Params
|
|
flags := append(commonFlags(), getOrgFlags(¶ms.OrgParams)...)
|
|
flags = append(flags, &cli.StringSliceFlag{
|
|
Name: "id, i",
|
|
Usage: "Dashboard ID to retrieve",
|
|
})
|
|
return cli.Command{
|
|
Name: "dashboards",
|
|
Usage: "List Dashboard(s).",
|
|
Description: `List Dashboard(s).
|
|
|
|
Examples:
|
|
# list all known Dashboards
|
|
influx dashboards
|
|
|
|
# list all known Dashboards matching ids
|
|
influx dashboards --id $ID1 --id $ID2
|
|
|
|
# list all known Dashboards matching ids shorts
|
|
influx dashboards -i $ID1 -i $ID2
|
|
`,
|
|
Flags: flags,
|
|
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
|
Action: func(ctx *cli.Context) error {
|
|
if err := checkOrgFlags(¶ms.OrgParams); err != nil {
|
|
return err
|
|
}
|
|
rawIds := ctx.StringSlice("id")
|
|
params.Ids = rawIds
|
|
|
|
api := getAPI(ctx)
|
|
client := dashboards.Client{
|
|
CLI: getCLI(ctx),
|
|
DashboardsApi: api.DashboardsApi,
|
|
}
|
|
return client.List(getContext(ctx), ¶ms)
|
|
},
|
|
}
|
|
}
|