Add JSON formatted output for authenticate password cli command (#402)

This commit is contained in:
Christian Frichot authored and GitHub committed 2020-09-22 07:50:40 -04:00
1 parent 874a7180ea
commit 9e6c016223
1 file changed
+8
@@ -145,6 +145,14 @@ func (c *PasswordCommand) Run(args []string) int {
fmt.Sprintf(" Token: %s", token.Token),
fmt.Sprintf(" User ID: %s", token.UserId),
}))
case "json":
jsonOut, err := base.JsonFormatter{}.Format(result)
if err != nil {
c.UI.Error(fmt.Errorf("Error formatting as JSON: %w", err).Error())
return 1
}
c.UI.Output(string(jsonOut))
}
tokenName := "default"