Skip to content

Commit

Permalink
cmd: make caddy fmt hints more clear (#5378)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilylange authored Feb 16, 2023
1 parent 5ded580 commit bf54892
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion caddyconfig/caddyfile/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func FormattingDifference(filename string, body []byte) (caddyconfig.Warning, bo
return caddyconfig.Warning{
File: filename,
Line: line,
Message: "Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies",
Message: "Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies",
}, true
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/commandfuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,10 @@ func cmdFmt(fl Flags) (int, error) {
}

if warning, diff := caddyfile.FormattingDifference(formatCmdConfigFile, input); diff {
return caddy.ExitCodeFailedStartup, fmt.Errorf("%s:%d: Caddyfile input is not formatted", warning.File, warning.Line)
return caddy.ExitCodeFailedStartup, fmt.Errorf(`%s:%d: Caddyfile input is not formatted; Tip: use '--overwrite' to update your Caddyfile in-place instead of previewing it. Consult '--help' for more options`,
warning.File,
warning.Line,
)
}

return caddy.ExitCodeSuccess, nil
Expand Down

0 comments on commit bf54892

Please sign in to comment.