From fb889216eded6ecaace1a161015719cd20041421 Mon Sep 17 00:00:00 2001 From: Sean Darcy Date: Tue, 18 Dec 2018 04:17:16 +0000 Subject: [PATCH] Changed dumpConfig function to optionally save to file --- cmd/geth/config.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 59f759f0ea..936944ad35 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -198,7 +198,19 @@ func dumpConfig(ctx *cli.Context) error { if err != nil { return err } - io.WriteString(os.Stdout, comment) - os.Stdout.Write(out) + + if ctx.NArg() > 0 { + f, err := os.OpenFile(ctx.Args().Get(0), os.O_RDWR|os.O_CREATE, 0644) + if err != nil { + return err + } + defer f.Close() + f.WriteString(comment) + f.Write(out) + } else { + io.WriteString(os.Stdout, comment) + os.Stdout.Write(out) + } + return nil }