daemon: print a newline before errors
The `ipfs init` command prints out a ton of information which can make it hard to spot errors. Print a newline before these errors We could do this for every command but there are some tricky edge cases: 1. This would look funny if there's no other output. 2. It might mess break tools parsing the output (not expecting empty lines). License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Jan 8, 2019 at 13:20 UTC
5f048311900b365fe2e417d93651bf137eab19a2
1 file changed
+10
-1
cmd/ipfs/daemon.go
+10
-1
@@ -185,7 +185,7 @@ func defaultMux(path string) corehttp.ServeOption {
185
}
186
}
187
188
-func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
188
+func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) (_err error) {
189
// Inject metrics before we do anything
190
err := mprome.Inject()
191
if err != nil {
@@ -195,6 +195,15 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
195
// let the user know we're going.
196
fmt.Printf("Initializing daemon...\n")
197
198
+ defer func() {
199
+ if _err != nil {
200
+ // Print an extra line before any errors. This could go
201
+ // in the commands lib but doesn't really make sense for
202
+ // all commands.
203
+ fmt.Println()
204
+ }
205
+ }()
206
+
207
// print the ipfs version
208
printVersion()
209