cmd: make caddy fmt hints more clear (#5378)

This commit is contained in:
Emily Lange 2023-02-17 00:34:12 +01:00 committed by GitHub
parent 5ded580444
commit bf54892a73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -88,7 +88,7 @@ func FormattingDifference(filename string, body []byte) (caddyconfig.Warning, bo
return caddyconfig.Warning{ return caddyconfig.Warning{
File: filename, File: filename,
Line: line, 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 }, true
} }

View File

@ -589,7 +589,10 @@ func cmdFmt(fl Flags) (int, error) {
} }
if warning, diff := caddyfile.FormattingDifference(formatCmdConfigFile, input); diff { 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 return caddy.ExitCodeSuccess, nil