diff --git a/command/configtest.go b/command/configtest.go index 48f9541964..e945d9d8a2 100644 --- a/command/configtest.go +++ b/command/configtest.go @@ -16,7 +16,7 @@ type ConfigTestCommand struct { func (c *ConfigTestCommand) Help() string { helpText := ` -Usage: consul configtest [options] FILE_OR_DIRECTORY +Usage: consul configtest [options] DEPRECATED. Use the 'consul validate' command instead. diff --git a/command/validate.go b/command/validate.go index 55f7c76992..c37d97139b 100644 --- a/command/validate.go +++ b/command/validate.go @@ -16,7 +16,7 @@ type ValidateCommand struct { func (c *ValidateCommand) Help() string { helpText := ` -Usage: consul validate [options] FILE_OR_DIRECTORY +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 diff --git a/main.go b/main.go index 249e6e2538..1867a73f4c 100644 --- a/main.go +++ b/main.go @@ -37,10 +37,18 @@ func realMain() int { } } + // Filter out the configtest command from the help display + var included []string + for command := range Commands { + if command != "configtest" { + included = append(included, command) + } + } + cli := &cli.CLI{ Args: args, Commands: Commands, - HelpFunc: cli.BasicHelpFunc("consul"), + HelpFunc: cli.FilteredHelpFunc(included, cli.BasicHelpFunc("consul")), } exitCode, err := cli.Run() diff --git a/website/source/docs/commands/configtest.html.markdown b/website/source/docs/commands/configtest.html.markdown deleted file mode 100644 index 78a629271c..0000000000 --- a/website/source/docs/commands/configtest.html.markdown +++ /dev/null @@ -1,34 +0,0 @@ ---- -layout: "docs" -page_title: "Commands: ConfigTest" -sidebar_current: "docs-commands-configtest" -description: > - The `consul configtest` command tests that config files are valid by - attempting to parse them. Useful to ensure a configuration change will - not cause consul to fail after a restart. ---- - -# Consul ConfigTest - -The `consul configtest` command performs a basic sanity test on Consul -configuration files. For each file or directory given, the configtest command -will attempt to parse the contents just as the "consul agent" command would, -and catch any errors. This is useful to do a test of the configuration only, -without actually starting the agent. - -For more information on the format of Consul's configuration files, read the -consul agent [Configuration Files](/docs/agent/options.html#configuration_files) -section. - -## Usage - -Usage: `consul configtest [options]` - -At least one `-config-file` or `-config-dir` parameter must be given. Returns 0 -if the configuration is valid, or 1 if there are problems. The list of -available flags are: - -* `-config-file` - Path to a config file. May be specified multiple times. - -* `-config-dir` - Path to a directory of config files. All files ending in - `.json` in the directory will be included. May be specified multiple times. diff --git a/website/source/docs/commands/validate.html.markdown b/website/source/docs/commands/validate.html.markdown new file mode 100644 index 0000000000..d71339b673 --- /dev/null +++ b/website/source/docs/commands/validate.html.markdown @@ -0,0 +1,39 @@ +--- +layout: "docs" +page_title: "Commands: Validate" +sidebar_current: "docs-commands-validate" +description: > + The `consul validate` command tests that config files are valid by + attempting to parse them. Useful to ensure a configuration change will + not cause consul to fail after a restart. +--- + +# Consul Validate + +The `consul validate` command performs a basic sanity test on Consul +configuration files. For each file or directory given, the validate command +will attempt to parse the contents just as the "consul agent" command would, +and catch any errors. This is useful to do a test of the configuration only, +without actually starting the agent. + +For more information on the format of Consul's configuration files, read the +consul agent [Configuration Files](/docs/agent/options.html#configuration_files) +section. + +## Usage + +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 +contents just as the "consul agent" command would, and catch any errors. +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. + +```text +$ consul validate /etc/consul.d +Configuration is valid! +``` + diff --git a/website/source/layouts/docs.erb b/website/source/layouts/docs.erb index b36421f9c3..9d37c0615d 100644 --- a/website/source/layouts/docs.erb +++ b/website/source/layouts/docs.erb @@ -71,10 +71,6 @@ agent - > - configtest - - > event @@ -173,6 +169,11 @@ + > + validate + + + > version