From 16f14e96fcdd563caaa088558d92fa42c2430582 Mon Sep 17 00:00:00 2001 From: Jesse Bouwman Date: Wed, 8 Sep 2021 08:54:48 -0700 Subject: [PATCH] revert local encoder --- executor.go | 21 --------------------- http/responseemitter.go | 2 +- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/executor.go b/executor.go index 9ea40406..89b3fcf4 100644 --- a/executor.go +++ b/executor.go @@ -2,8 +2,6 @@ package cmds import ( "context" - "io" - "io/ioutil" "os" ) @@ -35,25 +33,6 @@ type executor struct { root *Command } -// GetLocalEncoder provides special treatment for text encoding -// when Command.DisplayCLI field is non-nil, by defining an -// Encoder that delegates to a nested emitter that consumes a Response -// and writes to the underlying io.Writer using DisplayCLI. -func GetLocalEncoder(req *Request, w io.Writer, def EncodingType) (EncodingType, Encoder, error) { - encType, enc, err := GetEncoder(req, w, def) - if err != nil { - return encType, nil, err - } - - if req.Command.DisplayCLI != nil && encType == Text { - emitter, response := NewChanResponsePair(req) - go req.Command.DisplayCLI(response, w, ioutil.Discard) - return encType, &emitterEncoder{emitter: emitter}, nil - } - - return encType, enc, nil -} - type emitterEncoder struct { emitter ResponseEmitter } diff --git a/http/responseemitter.go b/http/responseemitter.go index 9c99da53..e5d424e7 100644 --- a/http/responseemitter.go +++ b/http/responseemitter.go @@ -27,7 +27,7 @@ var ( // NewResponseEmitter returns a new ResponseEmitter. func NewResponseEmitter(w http.ResponseWriter, method string, req *cmds.Request, opts ...ResponseEmitterOption) (ResponseEmitter, error) { - encType, enc, err := cmds.GetLocalEncoder(req, w, cmds.JSON) + encType, enc, err := cmds.GetEncoder(req, w, cmds.JSON) if err != nil { return nil, err }