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

Code before:
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply")
			cmd.Flags().StringP("envfile", "f", "", "Environment file to load")
			cmd.Flags().BoolP("environ", "e", false, "Print environment")
			cmd.Flags().BoolP("resume", "r", false, "Use saved config, if any (and prefer over --config file)")
			cmd.Flags().BoolP("watch", "w", false, "Watch config file for changes and reload it automatically")
			cmd.Flags().StringP("pidfile", "", "", "Path of file to which to write process ID")
			cmd.Flags().StringP("pingback", "", "", "Echo confirmation bytes to this address on success")
			cmd.RunE = WrapCommandFuncForCobra(cmdRun)
		},
	})

	RegisterCommand(Command{
		Name:  "stop",
		Usage: "[--config <path> [--adapter <name>]] [--address <interface>]",
		Short: "Gracefully stops a started Caddy process",
		Long: `
Stops the background Caddy process as gracefully as possible.

It requires that the admin API is enabled and accessible, since it will
use the API's /stop endpoint. The address of this request can be customized
using the --address flag, or from the given --config, if not the default.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Configuration file to use to parse the admin address, if --address is not used")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply (when --config is used)")
			cmd.Flags().StringP("address", "d", "", "The address to use to reach the admin API endpoint, if not the default")
			cmd.RunE = WrapCommandFuncForCobra(cmdStop)
		},
	})

	RegisterCommand(Command{
		Name:  "reload",
		Usage: "--config <path> [--adapter <name>] [--address <interface>]",
		Short: "Changes the config of the running Caddy instance",
		Long: `
Gives the running Caddy instance a new configuration. This has the same effect
as POSTing a document to the /load API endpoint, but is convenient for simple
workflows revolving around config files.

Since the admin endpoint is configurable, the endpoint configuration is loaded
from the --address flag if specified; otherwise it is loaded from the given
config file; otherwise the default is assumed.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Configuration file (required)")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply")
			cmd.Flags().StringP("address", "d", "", "Address of the administration listener, if different from config")
			cmd.Flags().BoolP("force", "f", false, "Force config reload, even if it is the same")
			cmd.RunE = WrapCommandFuncForCobra(cmdReload)
		},
	})

Review comment (suggestion):
```suggestion
			cmd.Flags().StringP("address", "", "", "The address to use to reach the admin API endpoint, if not the default")
```

Code after:
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply")
			cmd.Flags().StringP("envfile", "", "", "Environment file to load")
			cmd.Flags().BoolP("environ", "e", false, "Print environment")
			cmd.Flags().BoolP("resume", "r", false, "Use saved config, if any (and prefer over --config file)")
			cmd.Flags().BoolP("watch", "w", false, "Watch config file for changes and reload it automatically")
			cmd.Flags().StringP("pidfile", "", "", "Path of file to which to write process ID")
			cmd.Flags().StringP("pingback", "", "", "Echo confirmation bytes to this address on success")
			cmd.RunE = WrapCommandFuncForCobra(cmdRun)
		},
	})

	RegisterCommand(Command{
		Name:  "stop",
		Usage: "[--config <path> [--adapter <name>]] [--address <interface>]",
		Short: "Gracefully stops a started Caddy process",
		Long: `
Stops the background Caddy process as gracefully as possible.

It requires that the admin API is enabled and accessible, since it will
use the API's /stop endpoint. The address of this request can be customized
using the --address flag, or from the given --config, if not the default.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Configuration file to use to parse the admin address, if --address is not used")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply (when --config is used)")
			cmd.Flags().StringP("address", "", "", "The address to use to reach the admin API endpoint, if not the default")
			cmd.RunE = WrapCommandFuncForCobra(cmdStop)
		},
	})

	RegisterCommand(Command{
		Name:  "reload",
		Usage: "--config <path> [--adapter <name>] [--address <interface>]",
		Short: "Changes the config of the running Caddy instance",
		Long: `
Gives the running Caddy instance a new configuration. This has the same effect
as POSTing a document to the /load API endpoint, but is convenient for simple
workflows revolving around config files.

Since the admin endpoint is configurable, the endpoint configuration is loaded
from the --address flag if specified; otherwise it is loaded from the given
config file; otherwise the default is assumed.
`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("config", "c", "", "Configuration file (required)")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply")
			cmd.Flags().StringP("address", "", "", "Address of the administration listener, if different from config")
			cmd.Flags().BoolP("force", "f", false, "Force config reload, even if it is the same")
			cmd.RunE = WrapCommandFuncForCobra(cmdReload)
		},
	})