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

Code before:
`,
		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{
		Name:  "fmt",
		Usage: "[--overwrite] [--diff] [<path>]",
		Short: "Formats a Caddyfile",
		Long: `
Formats the Caddyfile by adding proper indentation and spaces to improve
human readability. It prints the result to stdout.

If --overwrite is specified, the output will be written to the config file
directly instead of printing it.

If --diff is specified, the output will be compared against the input, and
lines will be prefixed with '-' and '+' where they differ. Note that
unchanged lines are prefixed with two spaces for alignment, and that this
is not a valid patch format.

If you wish you use stdin instead of a regular file, use - as the path.
When reading from stdin, the --overwrite flag has no effect: the result
is always printed to stdout.
`,
		CobraFunc: func(cmd *cobra.Command) {

Review comment (suggestion):
```suggestion
			cmd.Flags().StringP("envfile", "", "", "Environment file to load")
```

Code after:
`,
		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{
		Name:  "fmt",
		Usage: "[--overwrite] [--diff] [<path>]",
		Short: "Formats a Caddyfile",
		Long: `
Formats the Caddyfile by adding proper indentation and spaces to improve
human readability. It prints the result to stdout.

If --overwrite is specified, the output will be written to the config file
directly instead of printing it.

If --diff is specified, the output will be compared against the input, and
lines will be prefixed with '-' and '+' where they differ. Note that
unchanged lines are prefixed with two spaces for alignment, and that this
is not a valid patch format.

If you wish you use stdin instead of a regular file, use - as the path.
When reading from stdin, the --overwrite flag has no effect: the result
is always printed to stdout.
`,
		CobraFunc: func(cmd *cobra.Command) {