Skip to content

Commit

Permalink
cmds: use w.Write directly
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
  • Loading branch information
overbool committed Nov 6, 2018
1 parent 01dcf34 commit fea0cda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 9 additions & 4 deletions core/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"gx/ipfs/QmP2i47tnU23ijdshrZtuvrSkQPtf9HhsMb9fwGVe8owj2/jsondiff"
cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds"
config "gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config"
"gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit"
)

// ConfigUpdateOutput is config profile apply command's output
Expand Down Expand Up @@ -128,7 +128,9 @@ Set the value of the 'Datastore.Path' key:
if err != nil {
return err
}
fmt.Fprintln(w, string(buf))
buf = append(buf, byte('\n'))

w.Write(buf)
return nil
}),
},
Expand Down Expand Up @@ -175,7 +177,9 @@ NOTE: For security reasons, this command will omit your private key. If you woul
if err != nil {
return err
}
fmt.Fprintln(w, string(buf))
buf = append(buf, byte('\n'))
w.Write(buf)

return nil
}),
},
Expand Down Expand Up @@ -329,7 +333,8 @@ var configProfileApplyCmd = &cmds.Command{
diff := jsondiff.Compare(out.OldCfg, out.NewCfg)
buf := jsondiff.Format(diff)

fmt.Fprint(w, string(buf))
w.Write(buf)

return nil
}),
},
Expand Down
6 changes: 2 additions & 4 deletions core/commands/mount_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ baz

// error if we aren't running node in online mode
if nd.LocalMode() {
return err
return ErrNotOnline
}

fsdir, found := req.Options[mountIPFSPathOptionName].(string)
Expand All @@ -120,9 +120,7 @@ baz
Type: config.Mounts{},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, mounts *config.Mounts) error {
s := fmt.Sprintf("IPFS mounted at: %s\n", mounts.IPFS)
s += fmt.Sprintf("IPNS mounted at: %s\n", mounts.IPNS)
fmt.Fprint(w, s)
fmt.Fprintf(w, "IPFS mounted at: %s\nIPNS mounted at: %s\n", mounts.IPFS, mounts.IPNS)
return nil
}),
},
Expand Down

0 comments on commit fea0cda

Please sign in to comment.