From e885dff5800ede044261ee922be614c44346481c Mon Sep 17 00:00:00 2001 From: vishalnayak Date: Thu, 17 Sep 2015 10:05:56 -0400 Subject: [PATCH] CLI: Avoiding CR when printing specific fields --- command/read.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/command/read.go b/command/read.go index 48831c722..fb8a86b94 100644 --- a/command/read.go +++ b/command/read.go @@ -2,6 +2,7 @@ package command import ( "fmt" + "os" "strings" ) @@ -55,7 +56,12 @@ func (c *ReadCommand) Run(args []string) int { // Handle single field output if field != "" { if val, ok := secret.Data[field]; ok { - c.Ui.Output(val.(string)) + // c.Ui.Output() prints a CR character which in this case is + // not desired. Since Vault CLI currently only uses BasicUi, + // which writes to standard output, os.Stdout is used here to + // directly print the message. If mitchellh/cli exposes method + // to print without CR, this has to be replaced by that. + fmt.Fprintf(os.Stdout, val.(string)) return 0 } else { c.Ui.Error(fmt.Sprintf(