aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/commandfuncs.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/commandfuncs.go')
-rw-r--r--cmd/commandfuncs.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index a5c357cd7..2adf95bb3 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -560,10 +560,15 @@ func cmdValidateConfig(fl Flags) (int, error) {
func cmdFmt(fl Flags) (int, error) {
configFile := fl.Arg(0)
- if configFile == "" {
+ configFlag := fl.String("config")
+ if (len(fl.Args()) > 1) || (configFlag != "" && configFile != "") {
+ return caddy.ExitCodeFailedStartup, fmt.Errorf("fmt does not support multiple files %s %s", configFlag, strings.Join(fl.Args(), " "))
+ }
+ if configFile == "" && configFlag == "" {
configFile = "Caddyfile"
+ } else if configFile == "" {
+ configFile = configFlag
}
-
// as a special case, read from stdin if the file name is "-"
if configFile == "-" {
input, err := io.ReadAll(os.Stdin)