Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
cmd: fmt: --write -> --overwrite to make it clear it's destructive
Matthew Holt committed
Mar 15, 2020 at 21:18 UTC
c67c8e60ccba736ed06f6a86c1fa2922e81a285f
2 files changed
+6
-8
cmd/commandfuncs.go
+3
-5
@@ -514,14 +514,12 @@ func cmdValidateConfig(fl Flags) (int, error) {
514
return caddy.ExitCodeSuccess, nil
515
}
516
517
-func cmdFormatConfig(fl Flags) (int, error) {
518
- // Default path of file is Caddyfile
517
+func cmdFmt(fl Flags) (int, error) {
518
formatCmdConfigFile := fl.Arg(0)
519
if formatCmdConfigFile == "" {
520
formatCmdConfigFile = "Caddyfile"
521
}
523
-
524
- formatCmdWriteFlag := fl.Bool("write")
522
+ overwrite := fl.Bool("overwrite")
523
524
input, err := ioutil.ReadFile(formatCmdConfigFile)
525
if err != nil {
@@ -531,7 +529,7 @@ func cmdFormatConfig(fl Flags) (int, error) {
529
530
output := caddyfile.Format(input)
531
534
- if formatCmdWriteFlag {
532
+ if overwrite {
533
err = ioutil.WriteFile(formatCmdConfigFile, output, 0644)
534
if err != nil {
535
return caddy.ExitCodeFailedStartup, nil
cmd/commands.go
+3
-3
@@ -244,8 +244,8 @@ provisioning stages.`,
244
245
RegisterCommand(Command{
246
Name: "fmt",
247
- Func: cmdFormatConfig,
248
- Usage: "[--write] [<path>]",
247
+ Func: cmdFmt,
248
+ Usage: "[--overwrite] [<path>]",
249
Short: "Formats a Caddyfile",
250
Long: `
251
Formats the Caddyfile by adding proper indentation and spaces to improve
@@ -255,7 +255,7 @@ If --write is specified, the output will be written to the config file
255
directly instead of printing it.`,
256
Flags: func() *flag.FlagSet {
257
fs := flag.NewFlagSet("format", flag.ExitOnError)
258
- fs.Bool("write", false, "Over-write the output to specified file")
258
+ fs.Bool("overwrite", false, "Overwrite the input file with the results")
259
return fs
260
}(),
261
})