From d86fe916cbed89f56260bc22ebdd9270a08b64f6 Mon Sep 17 00:00:00 2001 From: David Wittman Date: Wed, 20 May 2015 21:43:47 -0500 Subject: [PATCH] Read from stdin with auth command --- command/auth.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/command/auth.go b/command/auth.go index 456dbc7257..5650a56d4f 100644 --- a/command/auth.go +++ b/command/auth.go @@ -1,7 +1,9 @@ package command import ( + "bufio" "fmt" + "io" "os" "sort" "strings" @@ -63,6 +65,17 @@ func (c *AuthCommand) Run(args []string) int { // token is where the final token will go handler := c.Handlers[method] + + if len(args) > 0 && args[0] == "-" { + stdin := bufio.NewReader(os.Stdin) + args[0], err = stdin.ReadString('\n') + if err != nil && err != io.EOF { + c.Ui.Error(fmt.Sprintf("Error reading from stdin: %s", err)) + return 1 + } + args[0] = strings.TrimSpace(args[0]) + } + if method == "" { token := "" if len(args) > 0 {