@cryptotaxi247 / kubo / commits / 4115e2315

block rm: use Marshalers instead of PostRun to process output

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Feb 19, 2017 at 21:02 UTC 4115e2315d4f1eb3b028c8f47cac859b94ddc85e
1 file changed +12 -14
core/commands/block.go
+12 -14
@@ -280,21 +280,19 @@ It takes a list of base58 encoded multihashs to remove.
280 }
281 res.SetOutput(ch)
282 },
283 - PostRun: func(req cmds.Request, res cmds.Response) {
284 - if res.Error() != nil {
285 - return
286 - }
287 - outChan, ok := res.Output().(<-chan interface{})
288 - if !ok {
289 - res.SetError(u.ErrCast(), cmds.ErrNormal)
290 - return
291 - }
292 - res.SetOutput(nil)
283 + Marshalers: cmds.MarshalerMap{
284 + cmds.Text: func(res cmds.Response) (io.Reader, error) {
285 + outChan, ok := res.Output().(<-chan interface{})
286 + if !ok {
287 + return nil, u.ErrCast()
288 + }
289
294 - err := util.ProcRmOutput(outChan, res.Stdout(), res.Stderr())
295 - if err != nil {
296 - res.SetError(err, cmds.ErrNormal)
297 - }
290 + err := util.ProcRmOutput(outChan, res.Stdout(), res.Stderr())
291 + if err != nil {
292 + return nil, err
293 + }
294 + return nil, nil
295 + },
296 },
297 Type: util.RemovedBlock{},
298 }