diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/commandfuncs.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index 28fa26e..20c662b 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -463,17 +463,22 @@ func cmdAdaptConfig(fl Flags) (int, error) { fmt.Errorf("reading input file: %v", err) } - opts := make(map[string]interface{}) - if adaptCmdPrettyFlag { - opts["pretty"] = "true" - } - opts["filename"] = adaptCmdInputFlag + opts := map[string]interface{}{"filename": adaptCmdInputFlag} adaptedConfig, warnings, err := cfgAdapter.Adapt(input, opts) if err != nil { return caddy.ExitCodeFailedStartup, err } + if adaptCmdPrettyFlag { + var prettyBuf bytes.Buffer + err = json.Indent(&prettyBuf, adaptedConfig, "", "\t") + if err != nil { + return caddy.ExitCodeFailedStartup, err + } + adaptedConfig = prettyBuf.Bytes() + } + // print warnings to stderr for _, warn := range warnings { msg := warn.Message |