Skip to content

Commit

Permalink
cmds/filestore: use PostRun in verify
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 3, 2018
1 parent cd7113c commit ed40684
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions core/commands/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,25 @@ For ERROR entries the error will also be printed to stderr.

return nil
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *filestore.ListRes) error {
if out.Status == filestore.StatusOtherError {
fmt.Fprintf(os.Stderr, "%s\n", out.ErrorMsg)
PostRun: cmds.PostRunMap{
cmds.CLI: func(res cmds.Response, re cmds.ResponseEmitter) error {
for {
v, err := res.Next()
if err != nil {
if err == io.EOF {
return nil
}
return err
}

list := v.(*filestore.ListRes)

if list.Status == filestore.StatusOtherError {
fmt.Fprintf(os.Stderr, "%s\n", list.ErrorMsg)
}
fmt.Fprintf(os.Stdout, "%s %s\n", list.Status.Format(), list.FormatLong())
}
fmt.Fprintf(w, "%s %s\n", out.Status.Format(), out.FormatLong())
return nil
}),
},
},
Type: filestore.ListRes{},
}
Expand Down

0 comments on commit ed40684

Please sign in to comment.