mirror of https://github.com/status-im/consul.git
commands: move kv command to separate pkg
This commit is contained in:
parent
aca803ca8d
commit
200199a875
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/hashicorp/consul/command/info"
|
||||
"github.com/hashicorp/consul/command/join"
|
||||
"github.com/hashicorp/consul/command/keygen"
|
||||
"github.com/hashicorp/consul/command/kv"
|
||||
"github.com/hashicorp/consul/command/validate"
|
||||
"github.com/hashicorp/consul/version"
|
||||
"github.com/mitchellh/cli"
|
||||
|
@ -114,12 +115,7 @@ func init() {
|
|||
},
|
||||
|
||||
"kv": func() (cli.Command, error) {
|
||||
return &KVCommand{
|
||||
BaseCommand: BaseCommand{
|
||||
Flags: FlagSetNone,
|
||||
UI: ui,
|
||||
},
|
||||
}, nil
|
||||
return kv.New(), nil
|
||||
},
|
||||
|
||||
"kv delete": func() (cli.Command, error) {
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
package command
|
||||
package kv
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/consul/command/flags"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
// KVCommand is a Command implementation that just shows help for
|
||||
// the subcommands nested below it.
|
||||
type KVCommand struct {
|
||||
BaseCommand
|
||||
func New() *cmd {
|
||||
return &cmd{}
|
||||
}
|
||||
|
||||
func (c *KVCommand) Run(args []string) int {
|
||||
type cmd struct{}
|
||||
|
||||
func (c *cmd) Run(args []string) int {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
func (c *KVCommand) Help() string {
|
||||
c.InitFlagSet()
|
||||
return c.HelpCommand(`
|
||||
Usage: consul kv <subcommand> [options] [args]
|
||||
func (c *cmd) Synopsis() string {
|
||||
return "Interact with the key-value store"
|
||||
}
|
||||
|
||||
func (c *cmd) Help() string {
|
||||
s := `Usage: consul kv <subcommand> [options] [args]
|
||||
|
||||
This command has subcommands for interacting with Consul's key-value
|
||||
store. Here are some simple examples, and more detailed examples are
|
||||
|
@ -39,11 +42,6 @@ Usage: consul kv <subcommand> [options] [args]
|
|||
|
||||
$ consul kv delete redis/config/connections
|
||||
|
||||
For more examples, ask for subcommand help or view the documentation.
|
||||
|
||||
`)
|
||||
}
|
||||
|
||||
func (c *KVCommand) Synopsis() string {
|
||||
return "Interact with the key-value store"
|
||||
For more examples, ask for subcommand help or view the documentation.`
|
||||
return flags.Usage(s, nil, nil, nil)
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package kv
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestKVCommand_noTabs(t *testing.T) {
|
||||
if strings.ContainsRune(New().Help(), '\t') {
|
||||
t.Fatal("usage has tabs")
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestKVCommand_implements(t *testing.T) {
|
||||
t.Parallel()
|
||||
var _ cli.Command = &KVCommand{}
|
||||
}
|
||||
|
||||
func TestKVCommand_noTabs(t *testing.T) {
|
||||
t.Parallel()
|
||||
assertNoTabs(t, new(KVCommand))
|
||||
}
|
Loading…
Reference in New Issue