|
@ -514,14 +514,12 @@ func cmdValidateConfig(fl Flags) (int, error) { |
|
|
return caddy.ExitCodeSuccess, nil |
|
|
return caddy.ExitCodeSuccess, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func cmdFormatConfig(fl Flags) (int, error) { |
|
|
func cmdFmt(fl Flags) (int, error) { |
|
|
// Default path of file is Caddyfile
|
|
|
|
|
|
formatCmdConfigFile := fl.Arg(0) |
|
|
formatCmdConfigFile := fl.Arg(0) |
|
|
if formatCmdConfigFile == "" { |
|
|
if formatCmdConfigFile == "" { |
|
|
formatCmdConfigFile = "Caddyfile" |
|
|
formatCmdConfigFile = "Caddyfile" |
|
|
} |
|
|
} |
|
|
|
|
|
overwrite := fl.Bool("overwrite") |
|
|
formatCmdWriteFlag := fl.Bool("write") |
|
|
|
|
|
|
|
|
|
|
|
input, err := ioutil.ReadFile(formatCmdConfigFile) |
|
|
input, err := ioutil.ReadFile(formatCmdConfigFile) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -531,7 +529,7 @@ func cmdFormatConfig(fl Flags) (int, error) { |
|
|
|
|
|
|
|
|
output := caddyfile.Format(input) |
|
|
output := caddyfile.Format(input) |
|
|
|
|
|
|
|
|
if formatCmdWriteFlag { |
|
|
if overwrite { |
|
|
err = ioutil.WriteFile(formatCmdConfigFile, output, 0644) |
|
|
err = ioutil.WriteFile(formatCmdConfigFile, output, 0644) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return caddy.ExitCodeFailedStartup, nil |
|
|
return caddy.ExitCodeFailedStartup, nil |
|
|