Skip to content

Commit

Permalink
Merge pull request #3708 from ipfs/kevina/block-rm-marshalers
Browse files Browse the repository at this point in the history
block rm: use Marshalers instead of PostRun to process output
  • Loading branch information
whyrusleeping committed Feb 20, 2017
2 parents 427ccfc + 4115e23 commit 9ff46fb
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions core/commands/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,19 @@ It takes a list of base58 encoded multihashs to remove.
}
res.SetOutput(ch)
},
PostRun: func(req cmds.Request, res cmds.Response) {
if res.Error() != nil {
return
}
outChan, ok := res.Output().(<-chan interface{})
if !ok {
res.SetError(u.ErrCast(), cmds.ErrNormal)
return
}
res.SetOutput(nil)
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
outChan, ok := res.Output().(<-chan interface{})
if !ok {
return nil, u.ErrCast()
}

err := util.ProcRmOutput(outChan, res.Stdout(), res.Stderr())
if err != nil {
res.SetError(err, cmds.ErrNormal)
}
err := util.ProcRmOutput(outChan, res.Stdout(), res.Stderr())
if err != nil {
return nil, err
}
return nil, nil
},
},
Type: util.RemovedBlock{},
}

0 comments on commit 9ff46fb

Please sign in to comment.