Debian Codegraph @

cmd/commands.go

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 // Copyright 2015 Matthew Holt and The Caddy Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package caddycmdscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/
16
17 import (
18 "flagscip-go gomod github.com/golang/go/src go1.25.1 flag/"
19 "fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/"
20 "osscip-go gomod github.com/golang/go/src go1.25.1 os/"
21 "regexpscip-go gomod github.com/golang/go/src go1.25.1 regexp/"
22 "stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/"
23 "syncscip-go gomod github.com/golang/go/src go1.25.1 sync/"
•24 "timescip-go gomod github.com/golang/go/src go1.25.1 time/"
25
26 "github.com/spf13/cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/"
27 "github.com/spf13/cobra/docscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/"
28
29 "github.com/caddyserver/caddy/v2scip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/"
30 )
31
•32 // CustomDate will be used by the cobra manpage generator to generate a
33 // reproducible timestamp. If the "Date" header passed to cobra is empty, it
34 // will derive the time at build time, which is not reproducible.
35 // can be passed to during `go build` with `-ldflags`:
36 //
37 // -ldflags '-X github.com/caddyserver/caddy/v2/cmd.CustomDate=DD.MM.YYYY'
38 var CustomDatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/CustomDate. string
39
40 // Command represents a subcommand. Name, Func,
41 // and Short are required.
42 type Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command# struct {
43 // The name of the subcommand. Must conform to the
44 // format described by the RegisterCommand() godoc.
45 // Required.
46 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name. string
47
48 // Usage is a brief message describing the syntax of
49 // the subcommand's flags and args. Use [] to indicate
50 // optional parameters and <> to enclose literal values
51 // intended to be replaced by the user. Do not prefix
52 // the string with "caddy" or the name of the command
53 // since these will be prepended for you; only include
54 // the actual parameters for this command.
55 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage. string
56
57 // Short is a one-line message explaining what the
58 // command does. Should not end with punctuation.
59 // Required.
60 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short. string
61
62 // Long is the full help text shown to the user.
63 // Will be trimmed of whitespace on both ends before
64 // being printed.
65 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long. string
66
67 // Flags is the flagset for command.
68 // This is ignored if CobraFunc is set.
69 Flagsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Flags. *flagscip-go gomod github.com/golang/go/src go1.25.1 flag/.FlagSetscip-go gomod github.com/golang/go/src go1.25.1 flag/FlagSet#
70
71 // Func is a function that executes a subcommand using
72 // the parsed flags. It returns an exit code and any
73 // associated error.
74 // Required if CobraFunc is not set.
75 Funcscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Func. CommandFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/CommandFunc#
76
77 // CobraFunc allows further configuration of the command
78 // via cobra's APIs. If this is set, then Func and Flags
79 // are ignored, with the assumption that they are set in
80 // this function. A caddycmd.WrapCommandFuncForCobra helper
81 // exists to simplify porting CommandFunc to Cobra's RunE.
82 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc. func(*cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#)
83 }
84
85 // CommandFunc is a command's function. It runs the
86 // command and returns the proper exit code along with
87 // any error that occurred.
88 type CommandFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/CommandFunc# func(Flagsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Flags#) (int, error)
89
90 // Commands returns a list of commands initialised by
91 // RegisterCommand
92 func Commandsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Commands().() map[string]Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command# {
93 commandsMuscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandsMu..RLockscip-go gomod github.com/golang/go/src go1.25.1 sync/RWMutex#RLock().()
94 defer commandsMuscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandsMu..RUnlockscip-go gomod github.com/golang/go/src go1.25.1 sync/RWMutex#RUnlock().()
95
96 return commandsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commands.
97 }
98
99 var (
100 commandsMuscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandsMu. syncscip-go gomod github.com/golang/go/src go1.25.1 sync/.RWMutexscip-go gomod github.com/golang/go/src go1.25.1 sync/RWMutex#
101 commandsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commands. = make(map[string]Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#)
102 )
103
104 func initscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/init().() {
105 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
106 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "start",
107 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "[--config <path> [--adapter <name>]] [--envfile <path>] [--watch] [--pidfile <file>]",
108 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Starts the Caddy process in the background and then returns",
109 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
110 Starts the Caddy process, optionally bootstrapped with an initial config file.
111 This command unblocks after the server starts running or fails to run.
112
113 If --envfile is specified, an environment file with environment variables
114 in the KEY=VALUE format will be loaded into the Caddy process.
115
116 On Windows, the spawned child process will remain attached to the terminal, so
117 closing the window will forcefully stop Caddy; to avoid forgetting this, try
118 using 'caddy run' instead to keep it in the foreground.
119 `,
120 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
121 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Configuration file")
122 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("adapter", "a", "", "Name of config adapter to apply")
123 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringSlicePscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringSliceP().("envfile", "", []string{}, "Environment file(s) to load")
124 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("watch", "w", false, "Reload changed config file automatically")
125 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("pidfile", "", "", "Path of file to which to write process ID")
126 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdStartscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdStart().)
127 },
128 })
129
130 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
131 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "run",
132 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "[--config <path> [--adapter <name>]] [--envfile <path>] [--environ] [--resume] [--watch] [--pidfile <file>]",
133 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: `Starts the Caddy process and blocks indefinitely`,
134 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
135 Starts the Caddy process, optionally bootstrapped with an initial config file,
136 and blocks indefinitely until the server is stopped; i.e. runs Caddy in
137 "daemon" mode (foreground).
138
139 If a config file is specified, it will be applied immediately after the process
140 is running. If the config file is not in Caddy's native JSON format, you can
141 specify an adapter with --adapter to adapt the given config file to
142 Caddy's native format. The config adapter must be a registered module. Any
143 warnings will be printed to the log, but beware that any adaptation without
144 errors will immediately be used. If you want to review the results of the
145 adaptation first, use the 'adapt' subcommand.
146
147 As a special case, if the current working directory has a file called
148 "Caddyfile" and the caddyfile config adapter is plugged in (default), then
149 that file will be loaded and used to configure Caddy, even without any command
150 line flags.
151
152 If --envfile is specified, an environment file with environment variables
153 in the KEY=VALUE format will be loaded into the Caddy process.
154
155 If --environ is specified, the environment as seen by the Caddy process will
156 be printed before starting. This is the same as the environ command but does
157 not quit after printing, and can be useful for troubleshooting.
158
159 The --resume flag will override the --config flag if there is a config auto-
160 save file. It is not an error if --resume is used and no autosave file exists.
161
162 If --watch is specified, the config file will be loaded automatically after
163 changes. ⚠️ This can make unintentional config changes easier; only use this
164 option in a local development environment.
165 `,
166 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
167 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Configuration file")
168 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("adapter", "a", "", "Name of config adapter to apply")
169 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringSlicePscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringSliceP().("envfile", "", []string{}, "Environment file(s) to load")
170 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("environ", "e", false, "Print environment")
171 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("resume", "r", false, "Use saved config, if any (and prefer over --config file)")
172 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("watch", "w", false, "Watch config file for changes and reload it automatically")
173 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("pidfile", "", "", "Path of file to which to write process ID")
174 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("pingback", "", "", "Echo confirmation bytes to this address on success")
175 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdRunscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdRun().)
176 },
177 })
178
179 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
180 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "stop",
181 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "[--config <path> [--adapter <name>]] [--address <interface>]",
182 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Gracefully stops a started Caddy process",
183 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
184 Stops the background Caddy process as gracefully as possible.
185
186 It requires that the admin API is enabled and accessible, since it will
187 use the API's /stop endpoint. The address of this request can be customized
188 using the --address flag, or from the given --config, if not the default.
189 `,
190 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
191 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Configuration file to use to parse the admin address, if --address is not used")
192 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("adapter", "a", "", "Name of config adapter to apply (when --config is used)")
193 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("address", "", "", "The address to use to reach the admin API endpoint, if not the default")
194 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdStopscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdStop().)
195 },
196 })
197
198 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
199 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "reload",
200 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "--config <path> [--adapter <name>] [--address <interface>]",
201 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Changes the config of the running Caddy instance",
202 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
203 Gives the running Caddy instance a new configuration. This has the same effect
204 as POSTing a document to the /load API endpoint, but is convenient for simple
205 workflows revolving around config files.
206
207 Since the admin endpoint is configurable, the endpoint configuration is loaded
208 from the --address flag if specified; otherwise it is loaded from the given
209 config file; otherwise the default is assumed.
210 `,
211 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
212 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Configuration file (required)")
213 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("adapter", "a", "", "Name of config adapter to apply")
214 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("address", "", "", "Address of the administration listener, if different from config")
215 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("force", "f", false, "Force config reload, even if it is the same")
216 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdReloadscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdReload().)
217 },
218 })
219
220 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
221 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "version",
222 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Prints the version",
223 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
224 Prints the version of this Caddy binary.
225
226 Version information must be embedded into the binary at compile-time in
227 order for Caddy to display anything useful with this command. If Caddy
228 is built from within a version control repository, the Go command will
229 embed the revision hash if available. However, if Caddy is built in the
230 way specified by our online documentation (or by using xcaddy), more
231 detailed version information is printed as given by Go modules.
232
233 For more details about the full version string, see the Go module
234 documentation: https://go.dev/doc/modules/version-numbers
235 `,
236 Funcscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Func.: cmdVersionscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdVersion().,
237 })
238
239 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
240 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "list-modules",
241 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "[--packages] [--versions] [--skip-standard] [--json]",
242 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Lists the installed Caddy modules",
243 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
244 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("packages", "", false, "Print package paths")
245 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("versions", "", false, "Print version information")
246 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("skip-standard", "s", false, "Skip printing standard modules")
247 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("json", "", false, "Print modules in JSON format")
248 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdListModulesscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdListModules().)
249 },
250 })
251
252 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
253 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "build-info",
254 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Prints information about this build",
255 Funcscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Func.: cmdBuildInfoscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdBuildInfo().,
256 })
257
258 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
259 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "environ",
260 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "[--envfile <path>]",
261 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Prints the environment",
262 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
263 Prints the environment as seen by this Caddy process.
264
265 The environment includes variables set in the system. If your Caddy
266 configuration uses environment variables (e.g. "{env.VARIABLE}") then
267 this command can be useful for verifying that the variables will have
268 the values you expect in your config.
269
270 If --envfile is specified, an environment file with environment variables
271 in the KEY=VALUE format will be loaded into the Caddy process.
272
273 Note that environments may be different depending on how you run Caddy.
274 Environments for Caddy instances started by service managers such as
275 systemd are often different than the environment inherited from your
276 shell or terminal.
277
278 You can also print the environment the same time you use "caddy run"
279 by adding the "--environ" flag.
280
281 Environments may contain sensitive data.
282 `,
283 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
284 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringSlicePscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringSliceP().("envfile", "", []string{}, "Environment file(s) to load")
285 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdEnvironscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdEnviron().)
286 },
287 })
288
289 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
290 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "adapt",
291 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "--config <path> [--adapter <name>] [--pretty] [--validate] [--envfile <path>]",
292 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Adapts a configuration to Caddy's native JSON",
293 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
294 Adapts a configuration to Caddy's native JSON format and writes the
295 output to stdout, along with any warnings to stderr.
296
297 If --pretty is specified, the output will be formatted with indentation
298 for human readability.
299
300 If --validate is used, the adapted config will be checked for validity.
301 If the config is invalid, an error will be printed to stderr and a non-
302 zero exit status will be returned.
303
304 If --envfile is specified, an environment file with environment variables
305 in the KEY=VALUE format will be loaded into the Caddy process.
306
307 If you wish to use stdin instead of a regular file, use - as the path.
308 `,
309 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
310 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Configuration file to adapt (required)")
311 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("adapter", "a", "caddyfile", "Name of config adapter")
312 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("pretty", "p", false, "Format the output for human readability")
313 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("validate", "", false, "Validate the output")
314 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringSlicePscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringSliceP().("envfile", "", []string{}, "Environment file(s) to load")
315 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdAdaptConfigscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdAdaptConfig().)
316 },
317 })
318
319 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
320 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "validate",
321 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "--config <path> [--adapter <name>] [--envfile <path>]",
322 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Tests whether a configuration file is valid",
323 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
324 Loads and provisions the provided config, but does not start running it.
325 This reveals any errors with the configuration through the loading and
326 provisioning stages.
327
328 If --envfile is specified, an environment file with environment variables
329 in the KEY=VALUE format will be loaded into the Caddy process.
330 `,
331 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
332 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Input configuration file")
333 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("adapter", "a", "", "Name of config adapter")
334 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringSlicePscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringSliceP().("envfile", "", []string{}, "Environment file(s) to load")
335 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdValidateConfigscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdValidateConfig().)
336 },
337 })
338
339 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
340 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "storage",
341 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Commands for working with Caddy's storage (EXPERIMENTAL)",
342 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
343 Allows exporting and importing Caddy's storage contents. The two commands can be
344 combined in a pipeline to transfer directly from one storage to another:
345
346 $ caddy storage export --config Caddyfile.old --output - |
347 > caddy storage import --config Caddyfile.new --input -
348
349 The - argument refers to stdout and stdin, respectively.
350
351 NOTE: When importing to or exporting from file_system storage (the default), the command
352 should be run as the user that owns the associated root path.
353
354 EXPERIMENTAL: May be changed or removed.
355 `,
356 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
357 exportCmd := &cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#{
358 Usescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Use.: "export --config <path> --output <path>",
359 Shortscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Short.: "Exports storage assets as a tarball",
360 Longscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Long.: `
361 The contents of the configured storage module (TLS certificates, etc)
362 are exported via a tarball.
363
364 --output is required, - can be given for stdout.
365 `,
366 RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE.: WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdExportStoragescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdExportStorage().),
367 }
368 exportCmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Input configuration file (required)")
369 exportCmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("output", "o", "", "Output path")
370 cmd.AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(exportCmd)
371
372 importCmd := &cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#{
373 Usescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Use.: "import --config <path> --input <path>",
374 Shortscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Short.: "Imports storage assets from a tarball.",
375 Longscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Long.: `
376 Imports storage assets to the configured storage module. The import file must be
377 a tar archive.
378
379 --input is required, - can be given for stdin.
380 `,
381 RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE.: WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdImportStoragescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdImportStorage().),
382 }
383 importCmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Configuration file to load (required)")
384 importCmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("input", "i", "", "Tar of assets to load (required)")
385 cmd.AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(importCmd)
386 },
387 })
388
389 RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
390 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "fmt",
391 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "[--overwrite] [--diff] [<path>]",
392 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Formats a Caddyfile",
393 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
394 Formats the Caddyfile by adding proper indentation and spaces to improve
395 human readability. It prints the result to stdout.
396
397 If --overwrite is specified, the output will be written to the config file
398 directly instead of printing it.
399
400 If --diff is specified, the output will be compared against the input, and
401 lines will be prefixed with '-' and '+' where they differ. Note that
402 unchanged lines are prefixed with two spaces for alignment, and that this
403 is not a valid patch format.
404
405 If you wish to use stdin instead of a regular file, use - as the path.
406 When reading from stdin, the --overwrite flag has no effect: the result
407 is always printed to stdout.
408 `,
409 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
410 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("config", "c", "", "Configuration file")
411 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("overwrite", "w", false, "Overwrite the input file with the results")
412 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().BoolPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#BoolP().("diff", "d", false, "Print the differences between the input file and the formatted output")
413 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(cmdFmtscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/cmdFmt().)
414 },
415 })
416
417 defaultFactoryscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/defaultFactory..Usescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/rootCommandFactory#Use().(func(rootCmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
418 manpageCommand := Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
419 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "manpage",
420 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "--directory <path>",
421 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Generates the manual pages for Caddy commands",
422 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: `
423 Generates the manual pages for Caddy commands into the designated directory
424 tagged into section 8 (System Administration).
425
426 The manual page files are generated into the directory specified by the
427 argument of --directory. If the directory does not exist, it will be created.
428 `,
429 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
430 cmd.Flagsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Flags().().StringPscip-go gomod github.com/spf13/pflag v1.0.10 `github.com/spf13/pflag`/FlagSet#StringP().("directory", "o", "", "The output directory where the manpages are generated")
431 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = WrapCommandFuncForCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/WrapCommandFuncForCobra().(func(fl Flagsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Flags#) (int, error) {
432 dir := stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25.1 strings/TrimSpace().(fl.Stringscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Flags#String().("directory"))
433 if dir == "" {
434 return caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ExitCodeFailedQuitscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ExitCodeFailedQuit., fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.1 fmt/Errorf().("designated output directory and specified section are required")
435 }
436 if err := osscip-go gomod github.com/golang/go/src go1.25.1 os/.MkdirAllscip-go gomod github.com/golang/go/src go1.25.1 os/MkdirAll().(dir, 0o755); err != nil {
437 return caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ExitCodeFailedQuitscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ExitCodeFailedQuit., err
438 }
•439 if CustomDatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/CustomDate. != "" {
440 date, _ := timescip-go gomod github.com/golang/go/src go1.25.1 time/.Parsescip-go gomod github.com/golang/go/src go1.25.1 time/Parse().(timescip-go gomod github.com/golang/go/src go1.25.1 time/.RFC3339scip-go gomod github.com/golang/go/src go1.25.1 time/RFC3339., CustomDatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/CustomDate.)
441 if err := docscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/.GenManTreescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManTree().(rootCmd, &docscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/.GenManHeaderscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManHeader#{
442 Titlescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManHeader#Title.: "Caddy",
443 Sectionscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManHeader#Section.: "8", // https://en.wikipedia.org/wiki/Man_page#Manual_sections
444 Datescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManHeader#Date.: &date,
445 }, dir); err != nil {
446 return caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ExitCodeFailedQuitscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ExitCodeFailedQuit., err
447 }
448 } else if err := docscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/.GenManTreescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManTree().(rootCmd, &docscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/.GenManHeaderscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManHeader#{
449 Titlescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManHeader#Title.: "Caddy",
450 Sectionscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra/doc`/GenManHeader#Section.: "8", // https://en.wikipedia.org/wiki/Man_page#Manual_sections
451 }, dir); err != nil {
452 return caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ExitCodeFailedQuitscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ExitCodeFailedQuit., err
453 }
454 return caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ExitCodeSuccessscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ExitCodeSuccess., nil
455 })
456 },
457 }
458
459 // source: https://github.com/spf13/cobra/blob/6dec1ae26659a130bdb4c985768d1853b0e1bc06/site/content/completions/_index.md
460 completionCommand := Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#{
461 Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.: "completion",
462 Usagescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Usage.: "[bash|zsh|fish|powershell]",
463 Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short.: "Generate completion script",
464 Longscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Long.: fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.1 fmt/Sprintf().(`To load completions:
465
466 Bash:
467
468 $ source <(%[1]s completion bash)
469
470 # To load completions for each session, execute once:
471 # Linux:
472 $ %[1]s completion bash > /etc/bash_completion.d/%[1]s
473 # macOS:
474 $ %[1]s completion bash > $(brew --prefix)/etc/bash_completion.d/%[1]s
475
476 Zsh:
477
478 # If shell completion is not already enabled in your environment,
479 # you will need to enable it. You can execute the following once:
480
481 $ echo "autoload -U compinit; compinit" >> ~/.zshrc
482
483 # To load completions for each session, execute once:
484 $ %[1]s completion zsh > "${fpath[1]}/_%[1]s"
485
486 # You will need to start a new shell for this setup to take effect.
487
488 fish:
489
490 $ %[1]s completion fish | source
491
492 # To load completions for each session, execute once:
493 $ %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish
494
495 PowerShell:
496
497 PS> %[1]s completion powershell | Out-String | Invoke-Expression
498
499 # To load completions for every new session, run:
500 PS> %[1]s completion powershell > %[1]s.ps1
501 # and source this file from your PowerShell profile.
502 `, rootCmd.Rootscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Root().().Namescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Name().()),
503 CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc.: func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
504 cmd.DisableFlagsInUseLinescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#DisableFlagsInUseLine. = true
505 cmd.ValidArgsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#ValidArgs. = []string{"bash", "zsh", "fish", "powershell"}
506 cmd.Argsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Args. = cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.MatchAllscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/MatchAll().(cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.ExactArgsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/ExactArgs().(1), cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.OnlyValidArgsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/OnlyValidArgs().)
507 cmd.RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE. = func(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#, args []string) error {
508 switch args[0] {
509 case "bash":
510 return cmd.Rootscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Root().().GenBashCompletionscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#GenBashCompletion().(osscip-go gomod github.com/golang/go/src go1.25.1 os/.Stdoutscip-go gomod github.com/golang/go/src go1.25.1 os/Stdout.)
511 case "zsh":
512 return cmd.Rootscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Root().().GenZshCompletionscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#GenZshCompletion().(osscip-go gomod github.com/golang/go/src go1.25.1 os/.Stdoutscip-go gomod github.com/golang/go/src go1.25.1 os/Stdout.)
513 case "fish":
514 return cmd.Rootscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Root().().GenFishCompletionscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#GenFishCompletion().(osscip-go gomod github.com/golang/go/src go1.25.1 os/.Stdoutscip-go gomod github.com/golang/go/src go1.25.1 os/Stdout., true)
515 case "powershell":
516 return cmd.Rootscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Root().().GenPowerShellCompletionWithDescscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#GenPowerShellCompletionWithDesc().(osscip-go gomod github.com/golang/go/src go1.25.1 os/.Stdoutscip-go gomod github.com/golang/go/src go1.25.1 os/Stdout.)
517 default:
518 return fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.1 fmt/Errorf().("unrecognized shell: %s", args[0])
519 }
520 }
521 },
522 }
523
524 rootCmd.AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(caddyCmdToCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/caddyCmdToCobra().(manpageCommand))
525 rootCmd.AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(caddyCmdToCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/caddyCmdToCobra().(completionCommand))
526
527 // add manpage and completion commands to the map of
528 // available commands, because they're not registered
529 // through RegisterCommand.
530 commandsMuscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandsMu..Lockscip-go gomod github.com/golang/go/src go1.25.1 sync/RWMutex#Lock().()
531 commandsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commands.[manpageCommand.Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.] = manpageCommand
532 commandsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commands.[completionCommand.Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.] = completionCommand
533 commandsMuscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandsMu..Unlockscip-go gomod github.com/golang/go/src go1.25.1 sync/RWMutex#Unlock().()
534 })
535 }
536
537 // RegisterCommand registers the command cmd.
538 // cmd.Name must be unique and conform to the
539 // following format:
540 //
541 // - lowercase
542 // - ASCII lowercase letters, digits and hyphens only
543 // - cannot start or end with a hyphen
544 // - hyphen cannot be adjacent to another hyphen
545 //
546 // This function panics if the name is already registered,
547 // if the name does not meet the described format, or if
548 // any of the fields are missing from cmd.
549 //
550 // This function should be used in init().
551 func RegisterCommandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/RegisterCommand().(cmd Commandscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#) {
552 commandsMuscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandsMu..Lockscip-go gomod github.com/golang/go/src go1.25.1 sync/RWMutex#Lock().()
553 defer commandsMuscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandsMu..Unlockscip-go gomod github.com/golang/go/src go1.25.1 sync/RWMutex#Unlock().()
554
555 if cmd.Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name. == "" {
556 panic("command name is required")
557 }
558 if cmd.Funcscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Func. == nil && cmd.CobraFuncscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#CobraFunc. == nil {
559 panic("command function missing")
560 }
561 if cmd.Shortscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Short. == "" {
562 panic("command short string is required")
563 }
564 if _, exists := commandsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commands.[cmd.Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.]; exists {
565 panic("command already registered: " + cmd.Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.)
566 }
567 if !commandNameRegexscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandNameRegex..MatchStringscip-go gomod github.com/golang/go/src go1.25.1 regexp/Regexp#MatchString().(cmd.Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.) {
568 panic("invalid command name")
569 }
570 defaultFactoryscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/defaultFactory..Usescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/rootCommandFactory#Use().(func(rootCmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#) {
571 rootCmd.AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(caddyCmdToCobrascip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/caddyCmdToCobra().(cmd))
572 })
573 commandsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commands.[cmd.Namescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/Command#Name.] = cmd
574 }
575
576 var commandNameRegexscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/cmd`/commandNameRegex. = regexpscip-go gomod github.com/golang/go/src go1.25.1 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.1 regexp/MustCompile().(`^[a-z0-9]$|^([a-z0-9]+-?[a-z0-9]*)+[a-z0-9]$`)