Skip to content

Commit

Permalink
feat(cmd): add auth:whoami --all
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Fisher committed Jul 21, 2016
1 parent 32177aa commit 45d46e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
15 changes: 12 additions & 3 deletions cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 9 additions & 3 deletions parser/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 45d46e9

Please sign in to comment.