Update format to not use colored UI for json/yaml
This commit is contained in:
parent
38823efa70
commit
9b949cebd5
|
@ -28,6 +28,13 @@ func OutputList(ui cli.Ui, format string, secret *api.Secret) int {
|
|||
}
|
||||
|
||||
func outputWithFormat(ui cli.Ui, format string, secret *api.Secret, data interface{}) int {
|
||||
// If we had a colored UI, pull out the nested ui so we don't add escape
|
||||
// sequences for outputting json, etc.
|
||||
colorUI, ok := ui.(*cli.ColoredUi)
|
||||
if ok {
|
||||
ui = colorUI.Ui
|
||||
}
|
||||
|
||||
formatter, ok := Formatters[strings.ToLower(format)]
|
||||
if !ok {
|
||||
ui.Error(fmt.Sprintf("Invalid output format: %s", format))
|
||||
|
|
|
@ -24,18 +24,10 @@ func (m mockUi) AskSecret(_ string) (string, error) {
|
|||
m.t.FailNow()
|
||||
return "", nil
|
||||
}
|
||||
func (m mockUi) Output(s string) {
|
||||
output = s
|
||||
}
|
||||
func (m mockUi) Info(s string) {
|
||||
m.t.Log(s)
|
||||
}
|
||||
func (m mockUi) Error(s string) {
|
||||
m.t.Log(s)
|
||||
}
|
||||
func (m mockUi) Warn(s string) {
|
||||
m.t.Log(s)
|
||||
}
|
||||
func (m mockUi) Output(s string) { output = s }
|
||||
func (m mockUi) Info(s string) { m.t.Log(s) }
|
||||
func (m mockUi) Error(s string) { m.t.Log(s) }
|
||||
func (m mockUi) Warn(s string) { m.t.Log(s) }
|
||||
|
||||
func TestJsonFormatter(t *testing.T) {
|
||||
ui := mockUi{t: t, SampleData: "something"}
|
||||
|
|
Loading…
Reference in New Issue