mirror of https://github.com/status-im/consul.git
commands: move snapshot command to separate pkg
This commit is contained in:
parent
4d6a0b94dd
commit
c8992cbe28
|
@ -37,6 +37,7 @@ import (
|
|||
"github.com/hashicorp/consul/command/reload"
|
||||
"github.com/hashicorp/consul/command/rtt"
|
||||
"github.com/hashicorp/consul/command/validate"
|
||||
"github.com/hashicorp/consul/snapshot"
|
||||
"github.com/hashicorp/consul/version"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
@ -187,9 +188,7 @@ func init() {
|
|||
},
|
||||
|
||||
"snapshot": func() (cli.Command, error) {
|
||||
return &SnapshotCommand{
|
||||
UI: ui,
|
||||
}, nil
|
||||
return snapshot.New(), nil
|
||||
},
|
||||
|
||||
"snapshot restore": func() (cli.Command, error) {
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
package command
|
||||
package snapshot
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
// SnapshotCommand is a Command implementation that just shows help for
|
||||
// the subcommands nested below it.
|
||||
type SnapshotCommand struct {
|
||||
UI cli.Ui
|
||||
func New() *cmd {
|
||||
return &cmd{}
|
||||
}
|
||||
|
||||
func (c *SnapshotCommand) Run(args []string) int {
|
||||
type cmd struct{}
|
||||
|
||||
func (c *cmd) Run(args []string) int {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
func (c *SnapshotCommand) Help() string {
|
||||
func (c *cmd) Synopsis() string {
|
||||
return "Saves, restores and inspects snapshots of Consul server state"
|
||||
}
|
||||
|
||||
func (c *cmd) Help() string {
|
||||
return `Usage: consul snapshot <subcommand> [options] [args]
|
||||
|
||||
This command has subcommands for saving, restoring, and inspecting the state
|
||||
|
@ -45,7 +49,3 @@ func (c *SnapshotCommand) Help() string {
|
|||
For more examples, ask for subcommand help or view the documentation.
|
||||
`
|
||||
}
|
||||
|
||||
func (c *SnapshotCommand) Synopsis() string {
|
||||
return "Saves, restores and inspects snapshots of Consul server state"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package snapshot
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSnapshotCommand_noTabs(t *testing.T) {
|
||||
t.Parallel()
|
||||
if strings.ContainsRune(New().Help(), '\t') {
|
||||
t.Fatal("usage has tabs")
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestSnapshotCommand_implements(t *testing.T) {
|
||||
t.Parallel()
|
||||
var _ cli.Command = &SnapshotCommand{}
|
||||
}
|
||||
|
||||
func TestSnapshotCommand_noTabs(t *testing.T) {
|
||||
t.Parallel()
|
||||
assertNoTabs(t, new(SnapshotCommand))
|
||||
}
|
Loading…
Reference in New Issue