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", "", 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().StringSliceP("envfile", "", []string{}, "Environment file to load")
			cmd.RunE = WrapCommandFuncForCobra(cmdValidateConfig)
		},
	})

	RegisterCommand(Command{
		Name:  "storage",
		Short: "Commands for working with Caddy's storage (EXPERIMENTAL)",
		Long: `
Allows exporting and importing Caddy's storage contents. The two commands can be
combined in a pipeline to transfer directly from one storage to another:

$ caddy storage export --config Caddyfile.old --output - |
> caddy storage import --config Caddyfile.new --input -

The - argument refers to stdout and stdin, respectively.

NOTE: When importing to or exporting from file_system storage (the default), the command
should be run as the user that owns the associated root path.

EXPERIMENTAL: May be changed or removed.
`,
		CobraFunc: func(cmd *cobra.Command) {
			exportCmd := &cobra.Command{
				Use:   "export --config <path> --output <path>",
				Short: "Exports storage assets as a tarball",

Review comment (suggestion):
```suggestion
			cmd.Flags().StringSliceP("envfile", "", []string{}, "Environment file(s) 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().StringSliceP("envfile", "", []string{}, "Environment file(s) to load")
			cmd.RunE = WrapCommandFuncForCobra(cmdValidateConfig)
		},
	})

	RegisterCommand(Command{
		Name:  "storage",
		Short: "Commands for working with Caddy's storage (EXPERIMENTAL)",
		Long: `
Allows exporting and importing Caddy's storage contents. The two commands can be
combined in a pipeline to transfer directly from one storage to another:

$ caddy storage export --config Caddyfile.old --output - |
> caddy storage import --config Caddyfile.new --input -

The - argument refers to stdout and stdin, respectively.

NOTE: When importing to or exporting from file_system storage (the default), the command
should be run as the user that owns the associated root path.

EXPERIMENTAL: May be changed or removed.
`,
		CobraFunc: func(cmd *cobra.Command) {
			exportCmd := &cobra.Command{
				Use:   "export --config <path> --output <path>",
				Short: "Exports storage assets as a tarball",