Repository: caddyserver/caddy
File: modules/caddypki/command.go (Go)

Code before:
func init() {
	caddycmd.RegisterCommand(caddycmd.Command{
		Name:  "trust",
		Usage: "[--ca <id>] [--address <listen>] [--config <path> [--adapter <name>]]",
		Short: "Installs a CA certificate into local trust stores",
		Long: `
Adds a root certificate into the local trust stores.

Caddy will attempt to install its root certificates into the local
trust stores automatically when they are first generated, but it
might fail if Caddy doesn't have the appropriate permissions to
write to the trust store. This command is necessary to pre-install
the certificates before using them, if the server process runs as an
unprivileged user (such as via systemd).

By default, this command installs the root certificate for Caddy's
default CA (i.e. 'local'). You may specify the ID of another CA
with the --ca flag.

This command will attempt to connect to Caddy's admin API running at
'` + caddy.DefaultAdminListen + `' to fetch the root certificate. You may
explicitly specify the --address, or use the --config flag to load
the admin address from your config, if not using the default.`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("ca", "i", "", "The ID of the CA to trust (defaults to 'local')")
			cmd.Flags().StringP("address", "d", "", "Address of the administration API listener (if --config is not used)")
			cmd.Flags().StringP("config", "c", "", "Configuration file (if --address is not used)")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply (if --config is used)")
			cmd.RunE = caddycmd.WrapCommandFuncForCobra(cmdTrust)
		},
	})

	caddycmd.RegisterCommand(caddycmd.Command{
		Name:  "untrust",
		Usage: "[--cert <path>] | [[--ca <id>] [--address <listen>] [--config <path> [--adapter <name>]]]",
		Short: "Untrusts a locally-trusted CA certificate",
		Long: `
Untrusts a root certificate from the local trust store(s).

This command uninstalls trust; it does not necessarily delete the
root certificate from trust stores entirely. Thus, repeatedly
trusting and untrusting new certificates can fill up trust databases.

This command does not delete or modify certificate files from Caddy's
configured storage.

This command can be used in one of two ways. Either by specifying
which certificate to untrust by a direct path to the certificate
file with the --cert flag, or by fetching the root certificate for
the CA from the admin API (default behaviour).


Review comment (suggestion):
```suggestion
			cmd.Flags().StringP("address", "", "", "Address of the administration API listener (if --config is not used)")
```

Code after:
func init() {
	caddycmd.RegisterCommand(caddycmd.Command{
		Name:  "trust",
		Usage: "[--ca <id>] [--address <listen>] [--config <path> [--adapter <name>]]",
		Short: "Installs a CA certificate into local trust stores",
		Long: `
Adds a root certificate into the local trust stores.

Caddy will attempt to install its root certificates into the local
trust stores automatically when they are first generated, but it
might fail if Caddy doesn't have the appropriate permissions to
write to the trust store. This command is necessary to pre-install
the certificates before using them, if the server process runs as an
unprivileged user (such as via systemd).

By default, this command installs the root certificate for Caddy's
default CA (i.e. 'local'). You may specify the ID of another CA
with the --ca flag.

This command will attempt to connect to Caddy's admin API running at
'` + caddy.DefaultAdminListen + `' to fetch the root certificate. You may
explicitly specify the --address, or use the --config flag to load
the admin address from your config, if not using the default.`,
		CobraFunc: func(cmd *cobra.Command) {
			cmd.Flags().StringP("ca", "", "", "The ID of the CA to trust (defaults to 'local')")
			cmd.Flags().StringP("address", "", "", "Address of the administration API listener (if --config is not used)")
			cmd.Flags().StringP("config", "c", "", "Configuration file (if --address is not used)")
			cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply (if --config is used)")
			cmd.RunE = caddycmd.WrapCommandFuncForCobra(cmdTrust)
		},
	})

	caddycmd.RegisterCommand(caddycmd.Command{
		Name:  "untrust",
		Usage: "[--cert <path>] | [[--ca <id>] [--address <listen>] [--config <path> [--adapter <name>]]]",
		Short: "Untrusts a locally-trusted CA certificate",
		Long: `
Untrusts a root certificate from the local trust store(s).

This command uninstalls trust; it does not necessarily delete the
root certificate from trust stores entirely. Thus, repeatedly
trusting and untrusting new certificates can fill up trust databases.

This command does not delete or modify certificate files from Caddy's
configured storage.

This command can be used in one of two ways. Either by specifying
which certificate to untrust by a direct path to the certificate
file with the --cert flag, or by fetching the root certificate for
the CA from the admin API (default behaviour).