Adding type checking to ensure only BasicUi is affected

This commit is contained in:
vishalnayak
2015-09-17 11:37:21 -04:00
parent fceaea733e
commit fee64e16c2

View File

@@ -3,6 +3,7 @@ package command
import ( import (
"fmt" "fmt"
"os" "os"
"reflect"
"strings" "strings"
) )
@@ -60,8 +61,12 @@ func (c *ReadCommand) Run(args []string) int {
// not desired. Since Vault CLI currently only uses BasicUi, // not desired. Since Vault CLI currently only uses BasicUi,
// which writes to standard output, os.Stdout is used here to // which writes to standard output, os.Stdout is used here to
// directly print the message. If mitchellh/cli exposes method // directly print the message. If mitchellh/cli exposes method
// to print without CR, this has to be replaced by that. // to print without CR, this check needs to be removed.
fmt.Fprintf(os.Stdout, val.(string)) if reflect.TypeOf(c.Ui).String() == "*cli.BasicUi" {
fmt.Fprintf(os.Stdout, val.(string))
} else {
c.Ui.Output(val.(string))
}
return 0 return 0
} else { } else {
c.Ui.Error(fmt.Sprintf( c.Ui.Error(fmt.Sprintf(