feat: added functionality for remote list
subcommand (#273)
* feat: add remote list subcommand functionality * refactor: removed repeated code and improved help text
This commit is contained in:
@ -78,10 +78,12 @@ func newRemoteCreateCmd() cli.Command {
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
api := getAPI(ctx)
|
||||
|
||||
client := remote.Client{
|
||||
CLI: getCLI(ctx),
|
||||
RemoteConnectionsApi: getAPI(ctx).RemoteConnectionsApi,
|
||||
OrganizationsApi: getAPI(ctx).OrganizationsApi,
|
||||
RemoteConnectionsApi: api.RemoteConnectionsApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
|
||||
return client.Create(getContext(ctx), ¶ms)
|
||||
@ -102,14 +104,47 @@ func newRemoteDeleteCmd() cli.Command {
|
||||
}
|
||||
|
||||
func newRemoteListCmd() cli.Command {
|
||||
var params remote.ListParams
|
||||
return cli.Command{
|
||||
Name: "list",
|
||||
Usage: "List all remote connections",
|
||||
Aliases: []string{"find", "ls"},
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: commonFlags(),
|
||||
Action: func(ctx *cli.Context) {
|
||||
fmt.Println("remote list command was called")
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "Filter results to only connections with a specific name",
|
||||
Destination: ¶ms.Name,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "Local org ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "Local org name",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "remote-url",
|
||||
Usage: "Filter results to only connections for a specific remote URL",
|
||||
Destination: ¶ms.RemoteURL,
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
api := getAPI(ctx)
|
||||
|
||||
client := remote.Client{
|
||||
CLI: getCLI(ctx),
|
||||
RemoteConnectionsApi: api.RemoteConnectionsApi,
|
||||
OrganizationsApi: api.OrganizationsApi,
|
||||
}
|
||||
|
||||
return client.List(getContext(ctx), ¶ms)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user