From 252e0d3b3afd09b30192f89a56e1d2cf66fece7a Mon Sep 17 00:00:00 2001 From: Overbool Date: Tue, 30 Oct 2018 11:19:13 +0800 Subject: [PATCH] commands/object: use cmds.EmitOnce in single value License: MIT Signed-off-by: Overbool --- core/commands/object/diff.go | 2 +- core/commands/object/object.go | 10 +++++----- core/commands/object/patch.go | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/commands/object/diff.go b/core/commands/object/diff.go index 109fd79963c0..840e1cb64233 100644 --- a/core/commands/object/diff.go +++ b/core/commands/object/diff.go @@ -94,7 +94,7 @@ Example: } } - return res.Emit(&Changes{out}) + return cmds.EmitOnce(res, &Changes{out}) }, Type: Changes{}, Encoders: cmds.EncoderMap{ diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 11e63cae3974..18dbea660737 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -148,7 +148,7 @@ multihash. Links: outLinks, } - return res.Emit(out) + return cmds.EmitOnce(res, out) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Object) error { @@ -252,7 +252,7 @@ Supported values are: } } - return res.Emit(node) + return cmds.EmitOnce(res, node) }, Type: Node{}, Encoders: cmds.EncoderMap{ @@ -318,7 +318,7 @@ var ObjectStatCmd = &cmds.Command{ CumulativeSize: ns.CumulativeSize, } - return res.Emit(oldStat) + return cmds.EmitOnce(res, oldStat) }, Type: ipld.NodeStat{}, Encoders: cmds.EncoderMap{ @@ -419,7 +419,7 @@ And then run: return err } - return res.Emit(&Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Object) error { @@ -474,7 +474,7 @@ Available templates: return err } - return res.Emit(&Object{Hash: nd.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: nd.Cid().String()}) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Object) error { diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 60cca92d866e..aefc745cde47 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -49,7 +49,7 @@ the limit will not be respected by the network. cmdkit.StringArg("root", true, false, "The hash of the node to modify."), cmdkit.FileArg("data", true, false, "Data to append.").EnableStdin(), }, - Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error { + Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { api, err := cmdenv.GetApi(env) if err != nil { return err @@ -70,7 +70,7 @@ the limit will not be respected by the network. return err } - return cmds.EmitOnce(re, &Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) }, Type: &Object{}, Encoders: cmds.EncoderMap{ @@ -117,7 +117,7 @@ Example: return err } - return res.Emit(&Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) }, Type: Object{}, Encoders: cmds.EncoderMap{ @@ -156,7 +156,7 @@ Remove a Merkle-link from the given object and return the hash of the result. return err } - return res.Emit(&Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) }, Type: Object{}, Encoders: cmds.EncoderMap{ @@ -220,7 +220,7 @@ to a file containing 'bar', and returns the hash of the new object. return err } - return res.Emit(&Object{Hash: p.Cid().String()}) + return cmds.EmitOnce(res, &Object{Hash: p.Cid().String()}) }, Type: Object{}, Encoders: cmds.EncoderMap{