summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-03-15 21:18:31 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-03-15 21:18:31 -0600
commitc67c8e60ccba736ed06f6a86c1fa2922e81a285f (patch)
treecd9af29a403fb54e79bbb6a76b1b9c703df82dd9 /cmd
parent8f8ecd2e2a3e456739923e1284357bcf31b757fb (diff)
cmd: fmt: --write -> --overwrite to make it clear it's destructive
Diffstat (limited to 'cmd')
-rw-r--r--cmd/commandfuncs.go8
-rw-r--r--cmd/commands.go6
2 files changed, 6 insertions, 8 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index 6ef6821..65c02d8 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -514,14 +514,12 @@ func cmdValidateConfig(fl Flags) (int, error) {
return caddy.ExitCodeSuccess, nil
}
-func cmdFormatConfig(fl Flags) (int, error) {
- // Default path of file is Caddyfile
+func cmdFmt(fl Flags) (int, error) {
formatCmdConfigFile := fl.Arg(0)
if formatCmdConfigFile == "" {
formatCmdConfigFile = "Caddyfile"
}
-
- formatCmdWriteFlag := fl.Bool("write")
+ overwrite := fl.Bool("overwrite")
input, err := ioutil.ReadFile(formatCmdConfigFile)
if err != nil {
@@ -531,7 +529,7 @@ func cmdFormatConfig(fl Flags) (int, error) {
output := caddyfile.Format(input)
- if formatCmdWriteFlag {
+ if overwrite {
err = ioutil.WriteFile(formatCmdConfigFile, output, 0644)
if err != nil {
return caddy.ExitCodeFailedStartup, nil
diff --git a/cmd/commands.go b/cmd/commands.go
index f98fbfa..d4edc66 100644
--- a/cmd/commands.go
+++ b/cmd/commands.go
@@ -244,8 +244,8 @@ provisioning stages.`,
RegisterCommand(Command{
Name: "fmt",
- Func: cmdFormatConfig,
- Usage: "[--write] [<path>]",
+ Func: cmdFmt,
+ Usage: "[--overwrite] [<path>]",
Short: "Formats a Caddyfile",
Long: `
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
directly instead of printing it.`,
Flags: func() *flag.FlagSet {
fs := flag.NewFlagSet("format", flag.ExitOnError)
- fs.Bool("write", false, "Over-write the output to specified file")
+ fs.Bool("overwrite", false, "Overwrite the input file with the results")
return fs
}(),
})