From 1ec4e1590bd04f70124da29271bb71511c3fc3dc Mon Sep 17 00:00:00 2001 From: mcfarlm3 <58636946+mcfarlm3@users.noreply.github.com> Date: Fri, 3 Sep 2021 13:17:18 -0700 Subject: [PATCH] feat: stub out `remote` and `replication` commands and subcommands (#254) * feat: stubbed out remote and replication commands and subcommands * refactor: renamed remote.go file to match command * refactor: combined replication metrics and replication list subcommands into list only * refactor: removed extra appends to pass lint check --- cmd/influx/main.go | 2 ++ cmd/influx/remote.go | 71 +++++++++++++++++++++++++++++++++++++++ cmd/influx/replication.go | 71 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 cmd/influx/remote.go create mode 100644 cmd/influx/replication.go diff --git a/cmd/influx/main.go b/cmd/influx/main.go index 9ea53c9..8c963cc 100644 --- a/cmd/influx/main.go +++ b/cmd/influx/main.go @@ -54,6 +54,8 @@ var app = cli.App{ newApplyCmd(), newStacksCmd(), newTemplateCmd(), + newRemoteCmd(), + newReplicationCmd(), }, Before: withContext(), } diff --git a/cmd/influx/remote.go b/cmd/influx/remote.go new file mode 100644 index 0000000..0882570 --- /dev/null +++ b/cmd/influx/remote.go @@ -0,0 +1,71 @@ +package main + +import ( + "fmt" + + "github.com/influxdata/influx-cli/v2/pkg/cli/middleware" + "github.com/urfave/cli" +) + +func newRemoteCmd() cli.Command { + return cli.Command{ + Name: "remote", + Usage: "Remote connection management commands", + Hidden: true, // Remove this line when all subcommands are completed + Subcommands: []cli.Command{ + newRemoteCreateCmd(), + newRemoteDeleteCmd(), + newRemoteListCmd(), + newRemoteUpdateCmd(), + }, + } +} + +func newRemoteCreateCmd() cli.Command { + return cli.Command{ + Name: "create", + Usage: "Create a new remote connection", + Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs), + Flags: commonFlags(), + Action: func(ctx *cli.Context) { + fmt.Println("remote create command was called") + }, + } +} + +func newRemoteDeleteCmd() cli.Command { + return cli.Command{ + Name: "delete", + Usage: "Delete an existing remote connection", + Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs), + Flags: commonFlags(), + Action: func(ctx *cli.Context) { + fmt.Println("remote delete command was called") + }, + } +} + +func newRemoteListCmd() cli.Command { + 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") + }, + } +} + +func newRemoteUpdateCmd() cli.Command { + return cli.Command{ + Name: "update", + Usage: "Update an existing remote connection", + Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs), + Flags: commonFlags(), + Action: func(ctx *cli.Context) { + fmt.Println("remote update command was called") + }, + } +} diff --git a/cmd/influx/replication.go b/cmd/influx/replication.go new file mode 100644 index 0000000..7bd666c --- /dev/null +++ b/cmd/influx/replication.go @@ -0,0 +1,71 @@ +package main + +import ( + "fmt" + + "github.com/influxdata/influx-cli/v2/pkg/cli/middleware" + "github.com/urfave/cli" +) + +func newReplicationCmd() cli.Command { + return cli.Command{ + Name: "replication", + Usage: "Replication stream management commands", + Hidden: true, // Remove this line when all subcommands are completed + Subcommands: []cli.Command{ + newReplicationCreateCmd(), + newReplicationDeleteCmd(), + newReplicationListCmd(), + newReplicationUpdateCmd(), + }, + } +} + +func newReplicationCreateCmd() cli.Command { + return cli.Command{ + Name: "create", + Usage: "Create a new replication stream", + Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs), + Flags: commonFlags(), + Action: func(ctx *cli.Context) { + fmt.Println("replication create command was called") + }, + } +} + +func newReplicationDeleteCmd() cli.Command { + return cli.Command{ + Name: "delete", + Usage: "Delete an existing replication stream", + Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs), + Flags: commonFlags(), + Action: func(ctx *cli.Context) { + fmt.Println("replication delete command was called") + }, + } +} + +func newReplicationListCmd() cli.Command { + return cli.Command{ + Name: "list", + Usage: "List all replication streams and corresponding metrics", + Aliases: []string{"find", "ls"}, + Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs), + Flags: commonFlags(), + Action: func(ctx *cli.Context) { + fmt.Println("replication list command was called") + }, + } +} + +func newReplicationUpdateCmd() cli.Command { + return cli.Command{ + Name: "update", + Usage: "Update an existing replication stream", + Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs), + Flags: commonFlags(), + Action: func(ctx *cli.Context) { + fmt.Println("replication update command was called") + }, + } +}