CLI: Avoiding CR when printing specific fields
This commit is contained in:
parent
b08f6e5540
commit
e885dff580
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue