Skip to content

Commit

Permalink
commands/object: use cmds.EmitOnce in single value
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 Oct 30, 2018
1 parent f70a8e3 commit 252e0d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/commands/object/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Example:
}
}

return res.Emit(&Changes{out})
return cmds.EmitOnce(res, &Changes{out})
},
Type: Changes{},
Encoders: cmds.EncoderMap{
Expand Down
10 changes: 5 additions & 5 deletions core/commands/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -252,7 +252,7 @@ Supported values are:
}
}

return res.Emit(node)
return cmds.EmitOnce(res, node)
},
Type: Node{},
Encoders: cmds.EncoderMap{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions core/commands/object/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 252e0d3

Please sign in to comment.