Repository: caddyserver/caddy
File: cmd/commands.go (Go)

Code before:

Environments may contain sensitive data.
`,
		Func: cmdEnviron,
	})

	RegisterCommand(Command{
		Name:  "adapt",
		Usage: "--config <path> [--adapter <name>] [--pretty] [--validate]",
		Short: "Adapts a configuration to Caddy's native JSON",
		Long: `
Adapts a configuration to Caddy's native JSON format and writes the
output to stdout, along with any warnings to stderr.

If --pretty is specified, the output will be formatted with indentation
for human readability.

If --validate is used, the adapted config will be checked for validity.
If the config is invalid, an error will be printed to stderr and a non-
zero exit status will be returned.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Configuration file to adapt (required)")
			cmd.Flags().StringP("adapter", "a", "caddyfile", "Name of config adapter")
			cmd.Flags().BoolP("pretty", "p", false, "Format the output for human readability")
			cmd.Flags().BoolP("validate", "v", false, "Validate the output")
			cmd.RunE = WrapCommandFuncForCobra(cmdAdaptConfig)
		},
	})

	RegisterCommand(Command{
		Name:  "validate",
		Usage: "--config <path> [--adapter <name>] [--envfile <path>]",
		Short: "Tests whether a configuration file is valid",
		Long: `
Loads and provisions the provided config, but does not start running it.
This reveals any errors with the configuration through the loading and
provisioning stages.

If --envfile is specified, an environment file with environment variables in
the KEY=VALUE format will be loaded into the Caddy process.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Input configuration file")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter")
			cmd.Flags().StringP("envfile", "e", "", "Environment file to load")
			cmd.RunE = WrapCommandFuncForCobra(cmdValidateConfig)
		},
	})

	RegisterCommand(Command{

Review comment (suggestion):
```suggestion
			cmd.Flags().BoolP("validate", "", false, "Validate the output")
```

Code after:

Environments may contain sensitive data.
`,
		Func: cmdEnviron,
	})

	RegisterCommand(Command{
		Name:  "adapt",
		Usage: "--config <path> [--adapter <name>] [--pretty] [--validate]",
		Short: "Adapts a configuration to Caddy's native JSON",
		Long: `
Adapts a configuration to Caddy's native JSON format and writes the
output to stdout, along with any warnings to stderr.

If --pretty is specified, the output will be formatted with indentation
for human readability.

If --validate is used, the adapted config will be checked for validity.
If the config is invalid, an error will be printed to stderr and a non-
zero exit status will be returned.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Configuration file to adapt (required)")
			cmd.Flags().StringP("adapter", "a", "caddyfile", "Name of config adapter")
			cmd.Flags().BoolP("pretty", "p", false, "Format the output for human readability")
			cmd.Flags().BoolP("validate", "", false, "Validate the output")
			cmd.RunE = WrapCommandFuncForCobra(cmdAdaptConfig)
		},
	})

	RegisterCommand(Command{
		Name:  "validate",
		Usage: "--config <path> [--adapter <name>] [--envfile <path>]",
		Short: "Tests whether a configuration file is valid",
		Long: `
Loads and provisions the provided config, but does not start running it.
This reveals any errors with the configuration through the loading and
provisioning stages.

If --envfile is specified, an environment file with environment variables in
the KEY=VALUE format will be loaded into the Caddy process.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Input configuration file")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter")
			cmd.Flags().StringP("envfile", "", "", "Environment file to load")
			cmd.RunE = WrapCommandFuncForCobra(cmdValidateConfig)
		},
	})

	RegisterCommand(Command{