diff --git a/command/agent/agent.go b/command/agent/agent.go index cc932eb35a4c..9b6a0b36e998 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -54,7 +54,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string revision string version string versionPrerelease string @@ -70,15 +70,7 @@ type cmd struct { func (c *cmd) init() { c.flags = flag.NewFlagSet("", flag.ContinueOnError) config.AddFlags(c.flags, &c.flagArgs) - c.usage = flags.Usage(usage, c.flags, nil, nil) -} - -func (c *cmd) Synopsis() string { - return "Runs a Consul agent" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, nil, nil) } func (c *cmd) Run(args []string) int { @@ -499,7 +491,18 @@ func (c *cmd) handleReload(agent *agent.Agent, cfg *config.RuntimeConfig) (*conf return cfg, errs } -const usage = `Usage: consul agent [options] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Runs a Consul agent" +const help = ` +Usage: consul agent [options] Starts the Consul agent and runs until an interrupt is received. The - agent represents a single node in a cluster.` + agent represents a single node in a cluster. +` diff --git a/command/catalog/catalog.go b/command/catalog/catalog.go index 22945fe0abed..8c91610bd688 100644 --- a/command/catalog/catalog.go +++ b/command/catalog/catalog.go @@ -16,11 +16,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Interact with the catalog" + return synopsis } func (c *cmd) Help() string { - s := `Usage: consul catalog [options] [args] + return flags.Usage(help, nil, nil, nil) +} + +const synopsis = "Interact with the catalog" +const help = ` +Usage: consul catalog [options] [args] This command has subcommands for interacting with Consul's catalog. The catalog should not be confused with the agent, although the APIs and @@ -41,6 +46,5 @@ func (c *cmd) Help() string { $ consul catalog services - For more examples, ask for subcommand help or view the documentation.` - return flags.Usage(s, nil, nil, nil) -} + For more examples, ask for subcommand help or view the documentation. +` diff --git a/command/catalog/catalog_test.go b/command/catalog/catalog_test.go index 7b515f71ba70..576101016e0c 100644 --- a/command/catalog/catalog_test.go +++ b/command/catalog/catalog_test.go @@ -7,6 +7,6 @@ import ( func TestCatalogCommand_noTabs(t *testing.T) { if strings.ContainsRune(New().Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/catalog/list/dc/catalog_list_datacenters.go b/command/catalog/list/dc/catalog_list_datacenters.go index ad38466997db..dcea8c969b39 100644 --- a/command/catalog/list/dc/catalog_list_datacenters.go +++ b/command/catalog/list/dc/catalog_list_datacenters.go @@ -18,7 +18,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -26,7 +26,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -59,14 +59,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Lists all known datacenters" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul catalog datacenters [options] +const synopsis = "Lists all known datacenters" +const help = ` +Usage: consul catalog datacenters [options] Retrieves the list of all known datacenters. This datacenters are sorted in ascending order based on the estimated median round trip time from the servers @@ -76,4 +78,5 @@ const usage = `Usage: consul catalog datacenters [options] $ consul catalog datacenters - For a full list of options and examples, please see the Consul documentation.` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/catalog/list/dc/catalog_list_datacenters_test.go b/command/catalog/list/dc/catalog_list_datacenters_test.go index 26c6d57f66bc..87b07edf8168 100644 --- a/command/catalog/list/dc/catalog_list_datacenters_test.go +++ b/command/catalog/list/dc/catalog_list_datacenters_test.go @@ -10,7 +10,7 @@ import ( func TestCatalogListDatacentersCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/catalog/list/nodes/catalog_list_nodes.go b/command/catalog/list/nodes/catalog_list_nodes.go index 27a294b8e079..f0b78126cbf6 100644 --- a/command/catalog/list/nodes/catalog_list_nodes.go +++ b/command/catalog/list/nodes/catalog_list_nodes.go @@ -22,7 +22,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string // flags detailed bool @@ -48,8 +48,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -121,14 +120,6 @@ func (c *cmd) Run(args []string) int { return 0 } -func (c *cmd) Synopsis() string { - return "Lists all nodes in the given datacenter" -} - -func (c *cmd) Help() string { - return c.usage -} - // printNodes accepts a list of nodes and prints information in a tabular // format about the nodes. func printNodes(nodes []*api.Node, detailed bool) (string, error) { @@ -191,7 +182,17 @@ func mapToKV(m map[string]string, joiner string) string { return strings.Join(r, joiner) } -const usage = `Usage: consul catalog nodes [options] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Lists all nodes in the given datacenter" +const help = ` +Usage: consul catalog nodes [options] Retrieves the list nodes registered in a given datacenter. By default, the datacenter of the local agent is queried. @@ -217,4 +218,5 @@ const usage = `Usage: consul catalog nodes [options] $ consul catalog nodes -near=node-web - For a full list of options and examples, please see the Consul documentation.` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/catalog/list/nodes/catalog_list_nodes_test.go b/command/catalog/list/nodes/catalog_list_nodes_test.go index 1204aaf6a7e6..bc1916bfd3f5 100644 --- a/command/catalog/list/nodes/catalog_list_nodes_test.go +++ b/command/catalog/list/nodes/catalog_list_nodes_test.go @@ -10,7 +10,7 @@ import ( func TestCatalogListNodesCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/catalog/list/services/catalog_list_services.go b/command/catalog/list/services/catalog_list_services.go index f178406a22ac..bd14206cbfec 100644 --- a/command/catalog/list/services/catalog_list_services.go +++ b/command/catalog/list/services/catalog_list_services.go @@ -23,7 +23,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string // flags node string @@ -46,7 +46,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -126,14 +126,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Lists all registered services in a datacenter" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul catalog services [options] +const synopsis = "Lists all registered services in a datacenter" +const help = ` +Usage: consul catalog services [options] Retrieves the list services registered in a given datacenter. By default, the datacenter of the local agent is queried. @@ -154,4 +156,5 @@ const usage = `Usage: consul catalog services [options] $ consul catalog services -node-meta="foo=bar" - For a full list of options and examples, please see the Consul documentation.` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/catalog/list/services/catalog_list_services_test.go b/command/catalog/list/services/catalog_list_services_test.go index 5bb00d74f7e8..171e534ce1f3 100644 --- a/command/catalog/list/services/catalog_list_services_test.go +++ b/command/catalog/list/services/catalog_list_services_test.go @@ -11,7 +11,7 @@ import ( func TestCatalogListServicesCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/event/event.go b/command/event/event.go index 89eb912ceb6f..2eb16520b6ae 100644 --- a/command/event/event.go +++ b/command/event/event.go @@ -24,7 +24,7 @@ type cmd struct { node string service string tag string - usage string + help string } func (c *cmd) init() { @@ -40,7 +40,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), nil) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), nil) } func (c *cmd) Run(args []string) int { @@ -129,15 +129,18 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Fire a new event" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul event [options] [payload] +const synopsis = "Fire a new event" +const help = ` +Usage: consul event [options] [payload] Dispatches a custom user event across a datacenter. An event must provide a name, but a payload is optional. Events support filtering using - regular expressions on node name, service, and tag definitions.` + regular expressions on node name, service, and tag definitions. +` diff --git a/command/event/event_test.go b/command/event/event_test.go index d9df2bd0fca6..fdba0659a514 100644 --- a/command/event/event_test.go +++ b/command/event/event_test.go @@ -10,7 +10,7 @@ import ( func TestEventCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/exec/exec.go b/command/exec/exec.go index 877948565836..9728fb5a0b5b 100644 --- a/command/exec/exec.go +++ b/command/exec/exec.go @@ -29,7 +29,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string shutdownCh <-chan struct{} conf rExecConf @@ -60,7 +60,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -183,13 +183,23 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Executes a command on Consul nodes" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } +const synopsis = "Executes a command on Consul nodes" +const help = ` +Usage: consul exec [options] [-|command...] + + Evaluates a command on remote Consul nodes. The nodes responding can + be filtered using regular expressions on node name, service, and tag + definitions. If a command is '-', stdin will be read until EOF + and used as a script input. +` + // waitForJob is used to poll for results and wait until the job is terminated func (c *cmd) waitForJob() int { // Although the session destroy is already deferred, we do it again here, @@ -685,10 +695,3 @@ func (u *TargetedUI) prefixLines(arrow bool, message string) string { return strings.TrimRightFunc(result.String(), unicode.IsSpace) } - -const usage = `Usage: consul exec [options] [-|command...] - - Evaluates a command on remote Consul nodes. The nodes responding can - be filtered using regular expressions on node name, service, and tag - definitions. If a command is '-', stdin will be read until EOF - and used as a script input. ` diff --git a/command/exec/exec_test.go b/command/exec/exec_test.go index 4f8826f3cfcf..938b80479225 100644 --- a/command/exec/exec_test.go +++ b/command/exec/exec_test.go @@ -13,7 +13,7 @@ import ( func TestExecCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil, nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/forceleave/forceleave.go b/command/forceleave/forceleave.go index a8a951421ea0..fe917fa2b6c2 100644 --- a/command/forceleave/forceleave.go +++ b/command/forceleave/forceleave.go @@ -18,7 +18,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -26,7 +26,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -58,18 +58,21 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Forces a member of the cluster to enter the \"left\" state" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul force-leave [options] name +const synopsis = "Forces a member of the cluster to enter the \"left\" state" +const help = ` +Usage: consul force-leave [options] name Forces a member of a Consul cluster to enter the "left" state. Note that if the member is still actually alive, it will eventually rejoin the cluster. This command is most useful for cleaning out "failed" nodes that are never coming back. If you do not force leave a failed node, Consul will attempt to reconnect to those failed nodes for some period of - time before eventually reaping them.` + time before eventually reaping them. +` diff --git a/command/forceleave/forceleave_test.go b/command/forceleave/forceleave_test.go index f0afe4ae4da1..04ebb1d27df0 100644 --- a/command/forceleave/forceleave_test.go +++ b/command/forceleave/forceleave_test.go @@ -12,7 +12,7 @@ import ( func TestForceLeaveCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/info/info.go b/command/info/info.go index 3299112519fa..965c42e96080 100644 --- a/command/info/info.go +++ b/command/info/info.go @@ -19,14 +19,14 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { c.flags = flag.NewFlagSet("", flag.ContinueOnError) c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), nil) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), nil) } func (c *cmd) Run(args []string) int { @@ -84,13 +84,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Provides debugging information for operators." + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul info [options] +const synopsis = "Provides debugging information for operators." +const help = ` +Usage: consul info [options] - Provides debugging information for operators` + Provides debugging information for operators. +` diff --git a/command/info/info_test.go b/command/info/info_test.go index 59fca6e5c1b9..75605250fbac 100644 --- a/command/info/info_test.go +++ b/command/info/info_test.go @@ -10,7 +10,7 @@ import ( func TestInfoCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/join/join.go b/command/join/join.go index 2814f02196c1..5dfd83ec6819 100644 --- a/command/join/join.go +++ b/command/join/join.go @@ -18,7 +18,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string wan bool } @@ -29,7 +29,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), nil) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), nil) } func (c *cmd) Run(args []string) int { @@ -71,14 +71,17 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Tell Consul agent to join cluster" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul join [options] address ... +const synopsis = "Tell Consul agent to join cluster" +const help = ` +Usage: consul join [options] address ... Tells a running Consul agent (with "consul agent") to join the cluster - by specifying at least one existing member.` + by specifying at least one existing member. +` diff --git a/command/join/join_test.go b/command/join/join_test.go index d68246edfc2e..895b26ec0ae7 100644 --- a/command/join/join_test.go +++ b/command/join/join_test.go @@ -10,7 +10,7 @@ import ( func TestJoinCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/keygen/keygen.go b/command/keygen/keygen.go index 70a90bf091f0..b2f3d795b3ff 100644 --- a/command/keygen/keygen.go +++ b/command/keygen/keygen.go @@ -19,12 +19,12 @@ func New(ui cli.Ui) *cmd { type cmd struct { UI cli.Ui flags *flag.FlagSet - usage string + help string } func (c *cmd) init() { c.flags = flag.NewFlagSet("", flag.ContinueOnError) - c.usage = flags.Usage(usage, c.flags, nil, nil) + c.help = flags.Usage(help, c.flags, nil, nil) } func (c *cmd) Run(args []string) int { @@ -48,15 +48,18 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Generates a new encryption key" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul keygen +const synopsis = "Generates a new encryption key" +const help = ` +Usage: consul keygen Generates a new encryption key that can be used to configure the agent to encrypt traffic. The output of this command is already - in the proper format that the agent expects.` + in the proper format that the agent expects. +` diff --git a/command/keygen/keygen_test.go b/command/keygen/keygen_test.go index 38f336ef9a4b..6160ab1c2095 100644 --- a/command/keygen/keygen_test.go +++ b/command/keygen/keygen_test.go @@ -10,7 +10,7 @@ import ( func TestKeygenCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/keyring/keyring.go b/command/keyring/keyring.go index a7f46413e421..3b5265bf4a56 100644 --- a/command/keyring/keyring.go +++ b/command/keyring/keyring.go @@ -20,7 +20,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string // flags installKey string @@ -52,7 +52,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -162,14 +162,16 @@ func (c *cmd) handleList(responses []*consulapi.KeyringResponse) { } func (c *cmd) Synopsis() string { - return "Manages gossip layer encryption keys" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul keyring [options] +const synopsis = "Manages gossip layer encryption keys" +const help = ` +Usage: consul keyring [options] Manages encryption keys used for gossip messages. Gossip encryption is optional. When enabled, this command may be used to examine active encryption @@ -182,4 +184,5 @@ const usage = `Usage: consul keyring [options] All variations of the keyring command return 0 if all nodes reply and there are no errors. If any node fails to reply or reports failure, the exit code - will be 1.` + will be 1. +` diff --git a/command/keyring/keyring_test.go b/command/keyring/keyring_test.go index bb6248595dd3..5b706cc45a40 100644 --- a/command/keyring/keyring_test.go +++ b/command/keyring/keyring_test.go @@ -10,7 +10,7 @@ import ( func TestKeyringCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/kv/del/kv_delete.go b/command/kv/del/kv_delete.go index 5a26882fd057..50ab16275c56 100644 --- a/command/kv/del/kv_delete.go +++ b/command/kv/del/kv_delete.go @@ -19,7 +19,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string cas bool modifyIndex uint64 recurse bool @@ -39,7 +39,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -138,14 +138,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Removes data from the KV store" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul kv delete [options] KEY_OR_PREFIX +const synopsis = "Removes data from the KV store" +const help = ` +Usage: consul kv delete [options] KEY_OR_PREFIX Removes the value from Consul's key-value store at the given path. If no key exists at the path, no action is taken. @@ -159,4 +161,5 @@ const usage = `Usage: consul kv delete [options] KEY_OR_PREFIX $ consul kv delete -recurse foo This will delete the keys named "foo", "food", and "foo/bar/zip" if they - existed. ` + existed. +` diff --git a/command/kv/del/kv_delete_test.go b/command/kv/del/kv_delete_test.go index 6d42c195035c..bfe328223f5f 100644 --- a/command/kv/del/kv_delete_test.go +++ b/command/kv/del/kv_delete_test.go @@ -12,7 +12,7 @@ import ( func TestKVDeleteCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/kv/exp/kv_export.go b/command/kv/exp/kv_export.go index e6f7dd793e41..34e4de4c9e68 100644 --- a/command/kv/exp/kv_export.go +++ b/command/kv/exp/kv_export.go @@ -21,7 +21,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -29,7 +29,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -89,14 +89,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Exports a tree from the KV store as JSON" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul kv export [KEY_OR_PREFIX] +const synopsis = "Exports a tree from the KV store as JSON" +const help = ` +Usage: consul kv export [KEY_OR_PREFIX] Retrieves key-value pairs for the given prefix from Consul's key-value store, and writes a JSON representation to stdout. This can be used with the command @@ -104,4 +106,5 @@ const usage = `Usage: consul kv export [KEY_OR_PREFIX] $ consul kv export vault - For a full list of options and examples, please see the Consul documentation.` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/kv/exp/kv_export_test.go b/command/kv/exp/kv_export_test.go index a3560dd980b4..0a44b92f96de 100644 --- a/command/kv/exp/kv_export_test.go +++ b/command/kv/exp/kv_export_test.go @@ -14,7 +14,7 @@ import ( func TestKVExportCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/kv/get/kv_get.go b/command/kv/get/kv_get.go index bcdeb057284f..4192a51b2ffd 100644 --- a/command/kv/get/kv_get.go +++ b/command/kv/get/kv_get.go @@ -23,7 +23,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string base64encode bool detailed bool keys bool @@ -54,7 +54,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -175,11 +175,11 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Retrieves or lists data from the KV store" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } func prettyKVPair(w io.Writer, pair *api.KVPair, base64EncodeValue bool) error { @@ -202,7 +202,9 @@ func prettyKVPair(w io.Writer, pair *api.KVPair, base64EncodeValue bool) error { return tw.Flush() } -const usage = `Usage: consul kv get [options] [KEY_OR_PREFIX] +const synopsis = "Retrieves or lists data from the KV store" +const help = ` +Usage: consul kv get [options] [KEY_OR_PREFIX] Retrieves the value from Consul's key-value store at the given key name. If no key exists with that name, an error is returned. If a key exists with that @@ -230,4 +232,5 @@ const usage = `Usage: consul kv get [options] [KEY_OR_PREFIX] $ consul kv get -keys foo - For a full list of options and examples, please see the Consul documentation. ` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/kv/get/kv_get_test.go b/command/kv/get/kv_get_test.go index cc3c1d7d6960..a5c12c2ba785 100644 --- a/command/kv/get/kv_get_test.go +++ b/command/kv/get/kv_get_test.go @@ -12,7 +12,7 @@ import ( func TestKVGetCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/kv/imp/kv_import.go b/command/kv/imp/kv_import.go index 4d211cd42615..c6be3a5fd7a2 100644 --- a/command/kv/imp/kv_import.go +++ b/command/kv/imp/kv_import.go @@ -27,7 +27,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string // testStdin is the input for testing. testStdin io.Reader @@ -38,7 +38,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -91,14 +91,6 @@ func (c *cmd) Run(args []string) int { return 0 } -func (c *cmd) Synopsis() string { - return "Imports a tree stored as JSON to the KV store" -} - -func (c *cmd) Help() string { - return c.usage -} - func (c *cmd) dataFromArgs(args []string) (string, error) { var stdin io.Reader = os.Stdin if c.testStdin != nil { @@ -140,7 +132,17 @@ func (c *cmd) dataFromArgs(args []string) (string, error) { } } -const usage = `Usage: consul kv import [DATA] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Imports a tree stored as JSON to the KV store" +const help = ` +Usage: consul kv import [DATA] Imports key-value pairs to the key-value store from the JSON representation generated by the "consul kv export" command. @@ -157,4 +159,5 @@ const usage = `Usage: consul kv import [DATA] Alternatively the data may be provided as the final parameter to the command, though care must be taken with regards to shell escaping. - For a full list of options and examples, please see the Consul documentation.` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/kv/imp/kv_import_test.go b/command/kv/imp/kv_import_test.go index b8b3ee91ffa8..408bb8c96c79 100644 --- a/command/kv/imp/kv_import_test.go +++ b/command/kv/imp/kv_import_test.go @@ -10,7 +10,7 @@ import ( func TestKVImportCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/kv/kv.go b/command/kv/kv.go index a1a9afa9988f..52be305ec737 100644 --- a/command/kv/kv.go +++ b/command/kv/kv.go @@ -16,11 +16,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Interact with the key-value store" + return synopsis } func (c *cmd) Help() string { - s := `Usage: consul kv [options] [args] + return flags.Usage(help, nil, nil, nil) +} + +const synopsis = "Interact with the key-value store" +const help = ` +Usage: consul kv [options] [args] This command has subcommands for interacting with Consul's key-value store. Here are some simple examples, and more detailed examples are @@ -42,6 +47,5 @@ func (c *cmd) Help() string { $ consul kv delete redis/config/connections - For more examples, ask for subcommand help or view the documentation.` - return flags.Usage(s, nil, nil, nil) -} + For more examples, ask for subcommand help or view the documentation. +` diff --git a/command/kv/kv_test.go b/command/kv/kv_test.go index 1d833a67843d..8ba81650cbe9 100644 --- a/command/kv/kv_test.go +++ b/command/kv/kv_test.go @@ -7,6 +7,6 @@ import ( func TestKVCommand_noTabs(t *testing.T) { if strings.ContainsRune(New().Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/kv/put/kv_put.go b/command/kv/put/kv_put.go index 821ac8bf3cec..3dab4950d437 100644 --- a/command/kv/put/kv_put.go +++ b/command/kv/put/kv_put.go @@ -24,7 +24,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string // flags cas bool @@ -70,7 +70,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -172,14 +172,6 @@ func (c *cmd) Run(args []string) int { } } -func (c *cmd) Synopsis() string { - return "Sets or updates data in the KV store" -} - -func (c *cmd) Help() string { - return c.usage -} - func (c *cmd) dataFromArgs(args []string) (string, string, error) { var stdin io.Reader = os.Stdin if c.testStdin != nil { @@ -225,7 +217,17 @@ func (c *cmd) dataFromArgs(args []string) (string, string, error) { } } -const usage = `Usage: consul kv put [options] KEY [DATA] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Sets or updates data in the KV store" +const help = ` +Usage: consul kv put [options] KEY [DATA] Writes the data to the given path in the key-value store. The data can be of any type. @@ -255,4 +257,5 @@ const usage = `Usage: consul kv put [options] KEY [DATA] $ consul kv put -cas -modify-index=844 config/redis/maxconns 5 - Additional flags and more advanced use cases are detailed below.` + Additional flags and more advanced use cases are detailed below. +` diff --git a/command/kv/put/kv_put_test.go b/command/kv/put/kv_put_test.go index 971ec75aed20..ec023332321b 100644 --- a/command/kv/put/kv_put_test.go +++ b/command/kv/put/kv_put_test.go @@ -17,7 +17,7 @@ import ( func TestKVPutCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/leave/leave.go b/command/leave/leave.go index 3868d68e3f6a..261f9b808fac 100644 --- a/command/leave/leave.go +++ b/command/leave/leave.go @@ -18,7 +18,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -26,7 +26,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -56,13 +56,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Gracefully leaves the Consul cluster and shuts down" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul leave [options] +const synopsis = "Gracefully leaves the Consul cluster and shuts down" +const help = ` +Usage: consul leave [options] - Causes the agent to gracefully leave the Consul cluster and shutdown.` + Causes the agent to gracefully leave the Consul cluster and shutdown. +` diff --git a/command/leave/leave_test.go b/command/leave/leave_test.go index b098938dce36..f7d2a03086a4 100644 --- a/command/leave/leave_test.go +++ b/command/leave/leave_test.go @@ -10,7 +10,7 @@ import ( func TestLeaveCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/lock/lock.go b/command/lock/lock.go index d6a6268e3933..728be01edc3e 100644 --- a/command/lock/lock.go +++ b/command/lock/lock.go @@ -42,7 +42,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string ShutdownCh <-chan struct{} @@ -103,7 +103,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -445,12 +445,12 @@ func (c *cmd) killChild(childErr chan error) error { return nil } -func (c *cmd) Help() string { - return c.usage +func (c *cmd) Synopsis() string { + return synopsis } -func (c *cmd) Synopsis() string { - return "Execute a command holding a lock" +func (c *cmd) Help() string { + return c.help } // LockUnlock is used to abstract over the differences between @@ -463,7 +463,9 @@ type LockUnlock struct { rawOpts interface{} } -const usage = `Usage: consul lock [options] prefix child... +const synopsis = "Execute a command holding a lock" +const help = ` +Usage: consul lock [options] prefix child... Acquires a lock or semaphore at a given path, and invokes a child process when successful. The child process can assume the lock is held while it @@ -479,5 +481,4 @@ const usage = `Usage: consul lock [options] prefix child... holders to coordinate. The prefix provided must have write privileges. - ` diff --git a/command/lock/lock_test.go b/command/lock/lock_test.go index 26f72000fd02..7cde7ea9eaf6 100644 --- a/command/lock/lock_test.go +++ b/command/lock/lock_test.go @@ -27,7 +27,7 @@ func argFail(t *testing.T, args []string, expected string) { func TestLockCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/maint/maint.go b/command/maint/maint.go index fbc7e3c64ba2..896315e9a1f0 100644 --- a/command/maint/maint.go +++ b/command/maint/maint.go @@ -13,7 +13,7 @@ import ( // node or service maintenance mode. type cmd struct { UI cli.Ui - usage string + help string flags *flag.FlagSet http *flags.HTTPFlags @@ -44,11 +44,7 @@ func (c *cmd) init() { c.flags.StringVar(&c.serviceID, "service", "", "Control maintenance mode for a specific service ID.") - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), nil) -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), nil) } func (c *cmd) Run(args []string) int { @@ -152,10 +148,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Controls node or service maintenance mode" + return synopsis } -const usage = `Usage: consul maint [options] +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Controls node or service maintenance mode" +const help = ` +Usage: consul maint [options] Places a node or service into maintenance mode. During maintenance mode, the node or service will be excluded from all queries through the DNS @@ -177,5 +179,4 @@ const usage = `Usage: consul maint [options] If no arguments are given, the agent's maintenance status will be shown. This will return blank if nothing is currently under maintenance. - ` diff --git a/command/maint/maint_test.go b/command/maint/maint_test.go index 1d54eaee1969..b7a22d5f71bd 100644 --- a/command/maint/maint_test.go +++ b/command/maint/maint_test.go @@ -11,7 +11,7 @@ import ( func TestMaintCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/members/members.go b/command/members/members.go index e4d69b95c5ed..697c5e5c0148 100644 --- a/command/members/members.go +++ b/command/members/members.go @@ -19,7 +19,7 @@ import ( // Consul agent what members are part of the cluster currently. type cmd struct { UI cli.Ui - usage string + help string flags *flag.FlagSet http *flags.HTTPFlags // flags @@ -51,11 +51,7 @@ func (c *cmd) init() { c.flags.StringVar(&c.segment, "segment", consulapi.AllSegments, "(Enterprise-only) If provided, output is filtered to only nodes in"+ "the given segment.") - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), nil) -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), nil) } func (c *cmd) Run(args []string) int { @@ -213,12 +209,16 @@ func (c *cmd) detailedOutput(members []*consulapi.AgentMember) []string { } func (c *cmd) Synopsis() string { - return "Lists the members of a Consul cluster" + return synopsis } -const usage = ` +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Lists the members of a Consul cluster" +const help = ` Usage: consul members [options] Outputs the members of a running Consul agent. - ` diff --git a/command/members/members_test.go b/command/members/members_test.go index 8de5ab79d707..8067e48d2733 100644 --- a/command/members/members_test.go +++ b/command/members/members_test.go @@ -11,7 +11,7 @@ import ( func TestMembersCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/monitor/monitor.go b/command/monitor/monitor.go index 6b488e5be9c5..3bff5cf6490e 100644 --- a/command/monitor/monitor.go +++ b/command/monitor/monitor.go @@ -13,7 +13,7 @@ import ( // Consul agent what members are part of the cluster currently. type cmd struct { UI cli.Ui - usage string + help string flags *flag.FlagSet http *flags.HTTPFlags @@ -40,11 +40,7 @@ func (c *cmd) init() { c.flags.StringVar(&c.logLevel, "log-level", "INFO", "Log level of the agent.") - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), nil) -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), nil) } func (c *cmd) Run(args []string) int { @@ -100,10 +96,15 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Stream logs from a Consul agent" + return synopsis } -const usage = ` +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Stream logs from a Consul agent" +const help = ` Usage: consul monitor [options] Shows recent log messages of a Consul agent, and attaches to the agent, @@ -111,5 +112,4 @@ Usage: consul monitor [options] listen for log levels that may be filtered out of the Consul agent. For example your agent may only be logging at INFO level, but with the monitor you can see the DEBUG level logs. - ` diff --git a/command/operator/autopilot/get/operator_autopilot_get.go b/command/operator/autopilot/get/operator_autopilot_get.go index 58dfd4d0db2f..da5dba4e705f 100644 --- a/command/operator/autopilot/get/operator_autopilot_get.go +++ b/command/operator/autopilot/get/operator_autopilot_get.go @@ -19,7 +19,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -27,15 +27,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) -} - -func (c *cmd) Synopsis() string { - return "Display the current Autopilot configuration" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -74,6 +66,17 @@ func (c *cmd) Run(args []string) int { return 0 } -const usage = `Usage: consul operator autopilot get-config [options] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Display the current Autopilot configuration" +const help = ` +Usage: consul operator autopilot get-config [options] -Displays the current Autopilot configuration.` + Displays the current Autopilot configuration. +` diff --git a/command/operator/autopilot/get/operator_autopilot_get_test.go b/command/operator/autopilot/get/operator_autopilot_get_test.go index e9f011167d81..9ef2aa1798cd 100644 --- a/command/operator/autopilot/get/operator_autopilot_get_test.go +++ b/command/operator/autopilot/get/operator_autopilot_get_test.go @@ -10,7 +10,7 @@ import ( func TestOperatorAutopilotGetConfigCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/operator/autopilot/operator_autopilot.go b/command/operator/autopilot/operator_autopilot.go index 02f361a02642..89b768a112e6 100644 --- a/command/operator/autopilot/operator_autopilot.go +++ b/command/operator/autopilot/operator_autopilot.go @@ -1,6 +1,7 @@ package autopilot import ( + "github.com/hashicorp/consul/command/flags" "github.com/mitchellh/cli" ) @@ -15,14 +16,17 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Provides tools for modifying Autopilot configuration" + return synopsis } func (c *cmd) Help() string { - s := `Usage: consul operator autopilot [options] + return flags.Usage(help, nil, nil, nil) +} -The Autopilot operator command is used to interact with Consul's Autopilot -subsystem. The command can be used to view or modify the current configuration.` +const synopsis = "Provides tools for modifying Autopilot configuration" +const help = ` +Usage: consul operator autopilot [options] - return s -} + The Autopilot operator command is used to interact with Consul's Autopilot + subsystem. The command can be used to view or modify the current configuration. +` diff --git a/command/operator/autopilot/operator_autopilot_test.go b/command/operator/autopilot/operator_autopilot_test.go index fcb6994f6884..cbd1d3b738d9 100644 --- a/command/operator/autopilot/operator_autopilot_test.go +++ b/command/operator/autopilot/operator_autopilot_test.go @@ -7,6 +7,6 @@ import ( func TestOperatorAutopilotCommand_noTabs(t *testing.T) { if strings.ContainsRune(New().Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/operator/autopilot/set/operator_autopilot_set.go b/command/operator/autopilot/set/operator_autopilot_set.go index 91ecdf56fe8f..93cf5419c786 100644 --- a/command/operator/autopilot/set/operator_autopilot_set.go +++ b/command/operator/autopilot/set/operator_autopilot_set.go @@ -20,7 +20,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string // flags cleanupDeadServers flags.BoolValue @@ -62,15 +62,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) -} - -func (c *cmd) Synopsis() string { - return "Modify the current Autopilot configuration" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -129,6 +121,17 @@ func (c *cmd) Run(args []string) int { return 1 } -const usage = `Usage: consul operator autopilot set-config [options] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Modify the current Autopilot configuration" +const help = ` +Usage: consul operator autopilot set-config [options] -Modifies the current Autopilot configuration.` + Modifies the current Autopilot configuration. +` diff --git a/command/operator/autopilot/set/operator_autopilot_set_test.go b/command/operator/autopilot/set/operator_autopilot_set_test.go index f9ea8b8aa667..2f168898d10e 100644 --- a/command/operator/autopilot/set/operator_autopilot_set_test.go +++ b/command/operator/autopilot/set/operator_autopilot_set_test.go @@ -12,7 +12,7 @@ import ( func TestOperatorAutopilotSetConfigCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/operator/operator.go b/command/operator/operator.go index 2115fee449e7..8bdf41b2dc60 100644 --- a/command/operator/operator.go +++ b/command/operator/operator.go @@ -1,6 +1,7 @@ package operator import ( + "github.com/hashicorp/consul/command/flags" "github.com/mitchellh/cli" ) @@ -15,11 +16,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Provides cluster-level tools for Consul operators" + return synopsis } func (c *cmd) Help() string { - s := `Usage: consul operator [options] + return flags.Usage(help, nil, nil, nil) +} + +const synopsis = "Provides cluster-level tools for Consul operators" +const help = ` +Usage: consul operator [options] Provides cluster-level tools for Consul operators, such as interacting with the Raft subsystem. NOTE: Use this command with extreme caution, as improper @@ -32,5 +38,3 @@ func (c *cmd) Help() string { Run consul operator with no arguments for help on that subcommand. ` - return s -} diff --git a/command/operator/operator_test.go b/command/operator/operator_test.go index 010bffb8fe5c..3ed4a06808cc 100644 --- a/command/operator/operator_test.go +++ b/command/operator/operator_test.go @@ -7,6 +7,6 @@ import ( func TestOperatorCommand_noTabs(t *testing.T) { if strings.ContainsRune(New().Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/operator/raft/listpeers/operator_raft_list.go b/command/operator/raft/listpeers/operator_raft_list.go index 703a054148c7..6302f62995c3 100644 --- a/command/operator/raft/listpeers/operator_raft_list.go +++ b/command/operator/raft/listpeers/operator_raft_list.go @@ -20,7 +20,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -28,15 +28,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) -} - -func (c *cmd) Synopsis() string { - return "Display the current Raft peer configuration" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -94,6 +86,17 @@ func raftListPeers(client *api.Client, stale bool) (string, error) { return columnize.SimpleFormat(result), nil } -const usage = `Usage: consul operator raft list-peers [options] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Display the current Raft peer configuration" +const help = ` +Usage: consul operator raft list-peers [options] -Displays the current Raft peer configuration.` + Displays the current Raft peer configuration. +` diff --git a/command/operator/raft/listpeers/operator_raft_list_test.go b/command/operator/raft/listpeers/operator_raft_list_test.go index 20e443a2654d..ab302d980f0d 100644 --- a/command/operator/raft/listpeers/operator_raft_list_test.go +++ b/command/operator/raft/listpeers/operator_raft_list_test.go @@ -11,7 +11,7 @@ import ( func TestOperatorRaftListPeersCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/operator/raft/operator_raft.go b/command/operator/raft/operator_raft.go index ae7f2000d1c0..a10125c5cf90 100644 --- a/command/operator/raft/operator_raft.go +++ b/command/operator/raft/operator_raft.go @@ -1,6 +1,7 @@ package raft import ( + "github.com/hashicorp/consul/command/flags" "github.com/mitchellh/cli" ) @@ -15,17 +16,18 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Provides cluster-level tools for Consul operators" + return synopsis } func (c *cmd) Help() string { - s := ` + return flags.Usage(help, nil, nil, nil) +} + +const synopsis = "Provides cluster-level tools for Consul operators" +const help = ` Usage: consul operator raft [options] The Raft operator command is used to interact with Consul's Raft subsystem. The command can be used to verify Raft peers or in rare cases to recover quorum by removing invalid peers. - ` - return s -} diff --git a/command/operator/raft/operator_raft_test.go b/command/operator/raft/operator_raft_test.go index d53c37f7a59f..ddc33ea9696a 100644 --- a/command/operator/raft/operator_raft_test.go +++ b/command/operator/raft/operator_raft_test.go @@ -7,6 +7,6 @@ import ( func TestOperatorRaftCommand_noTabs(t *testing.T) { if strings.ContainsRune(New().Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/operator/raft/removepeer/operator_raft_remove.go b/command/operator/raft/removepeer/operator_raft_remove.go index f4303bc034aa..3a2d16512643 100644 --- a/command/operator/raft/removepeer/operator_raft_remove.go +++ b/command/operator/raft/removepeer/operator_raft_remove.go @@ -19,7 +19,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string // flags address string @@ -36,15 +36,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) -} - -func (c *cmd) Synopsis() string { - return "Remove a Consul server from the Raft configuration" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -99,13 +91,24 @@ func raftRemovePeers(address, id string, operator *api.Operator) error { return nil } -const usage = `Usage: consul operator raft remove-peer [options] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Remove a Consul server from the Raft configuration" +const help = ` +Usage: consul operator raft remove-peer [options] -Remove the Consul server with given -address from the Raft configuration. + Remove the Consul server with given -address from the Raft configuration. -There are rare cases where a peer may be left behind in the Raft quorum even -though the server is no longer present and known to the cluster. This command -can be used to remove the failed server so that it is no longer affects the Raft -quorum. If the server still shows in the output of the "consul members" command, -it is preferable to clean up by simply running "consul force-leave" instead of -this command.` + There are rare cases where a peer may be left behind in the Raft quorum even + though the server is no longer present and known to the cluster. This command + can be used to remove the failed server so that it is no longer affects the Raft + quorum. If the server still shows in the output of the "consul members" command, + it is preferable to clean up by simply running "consul force-leave" instead of + this command. +` diff --git a/command/operator/raft/removepeer/operator_raft_remove_test.go b/command/operator/raft/removepeer/operator_raft_remove_test.go index ac30e46b9fcd..c7ba1245aa1b 100644 --- a/command/operator/raft/removepeer/operator_raft_remove_test.go +++ b/command/operator/raft/removepeer/operator_raft_remove_test.go @@ -10,7 +10,7 @@ import ( func TestOperatorRaftRemovePeerCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/reload/reload.go b/command/reload/reload.go index e9b4354eff00..ca6fe648d7cb 100644 --- a/command/reload/reload.go +++ b/command/reload/reload.go @@ -18,7 +18,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -26,15 +26,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) -} - -func (c *cmd) Synopsis() string { - return "Triggers the agent to reload configuration files" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -57,7 +49,18 @@ func (c *cmd) Run(args []string) int { return 0 } -const usage = `Usage: consul reload +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Triggers the agent to reload configuration files" +const help = ` +Usage: consul reload Causes the agent to reload configurations. This can be used instead - of sending the SIGHUP signal to the agent.` + of sending the SIGHUP signal to the agent. +` diff --git a/command/reload/reload_test.go b/command/reload/reload_test.go index c357fe737a55..efed6eb93819 100644 --- a/command/reload/reload_test.go +++ b/command/reload/reload_test.go @@ -10,7 +10,7 @@ import ( func TestReloadCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/rtt/rtt.go b/command/rtt/rtt.go index ee482eaeafad..f300ef20a049 100644 --- a/command/rtt/rtt.go +++ b/command/rtt/rtt.go @@ -21,7 +21,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string // flags wan bool @@ -34,15 +34,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), nil) -} - -func (c *cmd) Synopsis() string { - return "Estimates network round trip time between nodes" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), nil) } func (c *cmd) Run(args []string) int { @@ -182,7 +174,17 @@ SHOW_RTT: return 0 } -const usage = `Usage: consul rtt [options] node1 [node2] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Estimates network round trip time between nodes" +const help = ` +Usage: consul rtt [options] node1 [node2] Estimates the round trip time between two nodes using Consul's network coordinate model of the cluster. @@ -198,4 +200,5 @@ const usage = `Usage: consul rtt [options] node1 [node2] It is not possible to measure between LAN coordinates and WAN coordinates because they are maintained by independent Serf gossip areas, so they are - not compatible.` + not compatible. +` diff --git a/command/rtt/rtt_test.go b/command/rtt/rtt_test.go index 98e0a12906cd..0b861cd11f7b 100644 --- a/command/rtt/rtt_test.go +++ b/command/rtt/rtt_test.go @@ -14,7 +14,7 @@ import ( func TestRTTCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/snapshot/inspect/snapshot_inspect.go b/command/snapshot/inspect/snapshot_inspect.go index 4974fc216155..9a83308af709 100644 --- a/command/snapshot/inspect/snapshot_inspect.go +++ b/command/snapshot/inspect/snapshot_inspect.go @@ -21,20 +21,12 @@ func New(ui cli.Ui) *cmd { type cmd struct { UI cli.Ui flags *flag.FlagSet - usage string + help string } func (c *cmd) init() { c.flags = flag.NewFlagSet("", flag.ContinueOnError) - c.usage = flags.Usage(usage, c.flags, nil, nil) -} - -func (c *cmd) Synopsis() string { - return "Displays information about a Consul snapshot file" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, nil, nil) } func (c *cmd) Run(args []string) int { @@ -85,7 +77,17 @@ func (c *cmd) Run(args []string) int { return 0 } -const usage = `Usage: consul snapshot inspect [options] FILE +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Displays information about a Consul snapshot file" +const help = ` +Usage: consul snapshot inspect [options] FILE Displays information about a snapshot file on disk. @@ -93,4 +95,5 @@ const usage = `Usage: consul snapshot inspect [options] FILE $ consul snapshot inspect backup.snap - For a full list of options and examples, please see the Consul documentation.` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/snapshot/inspect/snapshot_inspect_test.go b/command/snapshot/inspect/snapshot_inspect_test.go index 55433f383740..1e50f36145a5 100644 --- a/command/snapshot/inspect/snapshot_inspect_test.go +++ b/command/snapshot/inspect/snapshot_inspect_test.go @@ -14,7 +14,7 @@ import ( func TestSnapshotInpectCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/snapshot/restore/snapshot_restore.go b/command/snapshot/restore/snapshot_restore.go index af3aa49c7d5b..bc9611d1756b 100644 --- a/command/snapshot/restore/snapshot_restore.go +++ b/command/snapshot/restore/snapshot_restore.go @@ -19,7 +19,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -27,15 +27,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) -} - -func (c *cmd) Synopsis() string { - return "Restores snapshot of Consul server state" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -83,7 +75,17 @@ func (c *cmd) Run(args []string) int { return 0 } -const usage = `Usage: consul snapshot restore [options] FILE +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Restores snapshot of Consul server state" +const help = ` +Usage: consul snapshot restore [options] FILE Restores an atomic, point-in-time snapshot of the state of the Consul servers which includes key/value entries, service catalog, prepared queries, sessions, @@ -101,4 +103,5 @@ const usage = `Usage: consul snapshot restore [options] FILE $ consul snapshot restore backup.snap - For a full list of options and examples, please see the Consul documentation.` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/snapshot/restore/snapshot_restore_test.go b/command/snapshot/restore/snapshot_restore_test.go index bd1bd5fec6f5..198b989a84ff 100644 --- a/command/snapshot/restore/snapshot_restore_test.go +++ b/command/snapshot/restore/snapshot_restore_test.go @@ -14,7 +14,7 @@ import ( func TestSnapshotRestoreCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/snapshot/save/snapshot_save.go b/command/snapshot/save/snapshot_save.go index 70dbf9063ad9..9e15eff743c6 100644 --- a/command/snapshot/save/snapshot_save.go +++ b/command/snapshot/save/snapshot_save.go @@ -22,7 +22,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string } func (c *cmd) init() { @@ -30,15 +30,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) -} - -func (c *cmd) Synopsis() string { - return "Saves snapshot of Consul server state" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -113,7 +105,17 @@ func (c *cmd) Run(args []string) int { return 0 } -const usage = `Usage: consul snapshot save [options] FILE +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Saves snapshot of Consul server state" +const help = ` +Usage: consul snapshot save [options] FILE Retrieves an atomic, point-in-time snapshot of the state of the Consul servers which includes key/value entries, service catalog, prepared queries, sessions, @@ -131,4 +133,5 @@ const usage = `Usage: consul snapshot save [options] FILE $ consul snapshot save -stale backup.snap - For a full list of options and examples, please see the Consul documentation.` + For a full list of options and examples, please see the Consul documentation. +` diff --git a/command/snapshot/save/snapshot_save_test.go b/command/snapshot/save/snapshot_save_test.go index a601f24b1443..728ca90d6feb 100644 --- a/command/snapshot/save/snapshot_save_test.go +++ b/command/snapshot/save/snapshot_save_test.go @@ -13,7 +13,7 @@ import ( func TestSnapshotSaveCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } func TestSnapshotSaveCommand_Validation(t *testing.T) { diff --git a/command/snapshot/snapshot_command.go b/command/snapshot/snapshot_command.go index 5353b229a60d..9feb190a64a8 100644 --- a/command/snapshot/snapshot_command.go +++ b/command/snapshot/snapshot_command.go @@ -1,6 +1,7 @@ package snapshot import ( + "github.com/hashicorp/consul/command/flags" "github.com/mitchellh/cli" ) @@ -15,11 +16,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Saves, restores and inspects snapshots of Consul server state" + return synopsis } func (c *cmd) Help() string { - return `Usage: consul snapshot [options] [args] + return flags.Usage(help, nil, nil, nil) +} + +const synopsis = "Saves, restores and inspects snapshots of Consul server state" +const help = ` +Usage: consul snapshot [options] [args] This command has subcommands for saving, restoring, and inspecting the state of the Consul servers for disaster recovery. These are atomic, point-in-time @@ -48,4 +54,3 @@ func (c *cmd) Help() string { For more examples, ask for subcommand help or view the documentation. ` -} diff --git a/command/snapshot/snapshot_command_test.go b/command/snapshot/snapshot_command_test.go index e13a9892f230..755d35aeaf9f 100644 --- a/command/snapshot/snapshot_command_test.go +++ b/command/snapshot/snapshot_command_test.go @@ -7,6 +7,6 @@ import ( func TestSnapshotCommand_noTabs(t *testing.T) { if strings.ContainsRune(New().Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/validate/validate.go b/command/validate/validate.go index e489be015636..1f308cde0d87 100644 --- a/command/validate/validate.go +++ b/command/validate/validate.go @@ -19,14 +19,14 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet quiet bool - usage string + help string } func (c *cmd) init() { c.flags = flag.NewFlagSet("", flag.ContinueOnError) c.flags.BoolVar(&c.quiet, "quiet", false, "When given, a successful run will produce no output.") - c.usage = flags.Usage(usage, c.flags, nil, nil) + c.help = flags.Usage(help, c.flags, nil, nil) } func (c *cmd) Run(args []string) int { @@ -56,14 +56,16 @@ func (c *cmd) Run(args []string) int { } func (c *cmd) Synopsis() string { - return "Validate config files/directories" + return synopsis } func (c *cmd) Help() string { - return c.usage + return c.help } -const usage = `Usage: consul validate [options] FILE_OR_DIRECTORY... +const synopsis = "Validate config files/directories" +const help = ` +Usage: consul validate [options] FILE_OR_DIRECTORY... Performs a basic sanity test on Consul configuration files. For each file or directory given, the validate command will attempt to parse the @@ -71,4 +73,5 @@ const usage = `Usage: consul validate [options] FILE_OR_DIRECTORY... This is useful to do a test of the configuration only, without actually starting the agent. - Returns 0 if the configuration is valid, or 1 if there are problems.` + Returns 0 if the configuration is valid, or 1 if there are problems. +` diff --git a/command/validate/validate_test.go b/command/validate/validate_test.go index 041a0556b4bd..5d3f7217c304 100644 --- a/command/validate/validate_test.go +++ b/command/validate/validate_test.go @@ -13,7 +13,7 @@ import ( func TestValidateCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/version/version.go b/command/version/version.go index d21d1a05ac5b..9e67bda865dc 100644 --- a/command/version/version.go +++ b/command/version/version.go @@ -17,14 +17,6 @@ type cmd struct { version string } -func (c *cmd) Synopsis() string { - return "Prints the Consul version" -} - -func (c *cmd) Help() string { - return "" -} - func (c *cmd) Run(_ []string) int { c.UI.Output(fmt.Sprintf("Consul %s", c.version)) @@ -43,3 +35,11 @@ func (c *cmd) Run(_ []string) int { return 0 } + +func (c *cmd) Synopsis() string { + return "Prints the Consul version" +} + +func (c *cmd) Help() string { + return "" +} diff --git a/command/version/version_test.go b/command/version/version_test.go index bfb655fa1757..0d80db4e1984 100644 --- a/command/version/version_test.go +++ b/command/version/version_test.go @@ -9,6 +9,6 @@ import ( func TestVersionCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi(), "").Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } } diff --git a/command/watch/watch.go b/command/watch/watch.go index 9f4737cb6cfe..c138386b4b86 100644 --- a/command/watch/watch.go +++ b/command/watch/watch.go @@ -26,7 +26,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags - usage string + help string shutdownCh <-chan struct{} @@ -70,15 +70,7 @@ func (c *cmd) init() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) - c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) -} - -func (c *cmd) Synopsis() string { - return "Watch for changes in Consul" -} - -func (c *cmd) Help() string { - return c.usage + c.help = flags.Usage(help, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -241,11 +233,22 @@ func (c *cmd) Run(args []string) int { return errExit } -const usage = `Usage: consul watch [options] [child...] +func (c *cmd) Synopsis() string { + return synopsis +} + +func (c *cmd) Help() string { + return c.help +} + +const synopsis = "Watch for changes in Consul" +const help = ` +Usage: consul watch [options] [child...] Watches for changes in a given data view from Consul. If a child process is specified, it will be invoked with the latest results on changes. Otherwise, the latest values are dumped to stdout and the watch terminates. Providing the watch type is required, and other parameters may be required - or supported depending on the watch type.` + or supported depending on the watch type. +` diff --git a/command/watch/watch_test.go b/command/watch/watch_test.go index d89ba9e6c84b..4c48845120a1 100644 --- a/command/watch/watch_test.go +++ b/command/watch/watch_test.go @@ -10,7 +10,7 @@ import ( func TestWatchCommand_noTabs(t *testing.T) { if strings.ContainsRune(New(cli.NewMockUi(), nil).Help(), '\t') { - t.Fatal("usage has tabs") + t.Fatal("help has tabs") } }