From 45d46e95da9afcee3d68bc2dc092b31af3d93fae Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Thu, 21 Jul 2016 13:50:35 -0700 Subject: [PATCH] feat(cmd): add auth:whoami --all --- cmd/auth.go | 15 ++++++++++++--- parser/auth.go | 12 +++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/cmd/auth.go b/cmd/auth.go index cb10df84..8f1d7f94 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -247,15 +247,24 @@ func Cancel(username string, password string, yes bool) error { return nil } -// Whoami prints the logged in user. -func Whoami() error { +// Whoami prints the logged in user. If all is true, it fetches info from the controller to know +// more about the user. +func Whoami(all bool) error { s, err := settings.Load() if err != nil { return err } - fmt.Printf("You are %s at %s\n", s.Username, s.Client.ControllerURL.String()) + if all { + user, err := auth.Whoami(s.Client) + if err != nil { + return err + } + fmt.Println(user) + } else { + fmt.Printf("You are %s at %s\n", s.Username, s.Client.ControllerURL.String()) + } return nil } diff --git a/parser/auth.go b/parser/auth.go index 9daca433..dcdea3c3 100644 --- a/parser/auth.go +++ b/parser/auth.go @@ -169,14 +169,20 @@ func authWhoami(argv []string) error { usage := ` Displays the currently logged in user. -Usage: deis auth:whoami +Usage: deis auth:whoami [options] + +Options: + --all + fetch a more detailed description about the user. ` - if _, err := docopt.Parse(usage, argv, true, "", false, true); err != nil { + args, err := docopt.Parse(usage, argv, true, "", false, true) + + if err != nil { return err } - return cmd.Whoami() + return cmd.Whoami(args["--all"].(bool)) } func authCancel(argv []string) error {