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 25, 2016
1 parent 32177aa commit 8168ea1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 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: 6 additions & 6 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ import:
- package: gopkg.in/yaml.v2
- package: github.com/olekukonko/tablewriter
- package: github.com/deis/controller-sdk-go
version: 0bf2d4659de0df612b444a5f57fd75e78d276671
version: cd8ecc1f17db726e57586a4d149b60a25f3c4dc7
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 8168ea1

Please sign in to comment.