Skip to content

Commit 2b35225

Browse files
author
Matthew Fisher
authored
Merge pull request #145 from bacongobbler/auth-whoami
feat(cmd): add auth:whoami --all
2 parents 70df6e0 + 8168ea1 commit 2b35225

4 files changed

Lines changed: 28 additions & 13 deletions

File tree

cmd/auth.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,24 @@ func Cancel(username string, password string, yes bool) error {
247247
return nil
248248
}
249249

250-
// Whoami prints the logged in user.
251-
func Whoami() error {
250+
// Whoami prints the logged in user. If all is true, it fetches info from the controller to know
251+
// more about the user.
252+
func Whoami(all bool) error {
252253
s, err := settings.Load()
253254

254255
if err != nil {
255256
return err
256257
}
257258

258-
fmt.Printf("You are %s at %s\n", s.Username, s.Client.ControllerURL.String())
259+
if all {
260+
user, err := auth.Whoami(s.Client)
261+
if err != nil {
262+
return err
263+
}
264+
fmt.Println(user)
265+
} else {
266+
fmt.Printf("You are %s at %s\n", s.Username, s.Client.ControllerURL.String())
267+
}
259268
return nil
260269
}
261270

glide.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ import:
1515
- package: gopkg.in/yaml.v2
1616
- package: github.com/olekukonko/tablewriter
1717
- package: github.com/deis/controller-sdk-go
18-
version: 0bf2d4659de0df612b444a5f57fd75e78d276671
18+
version: cd8ecc1f17db726e57586a4d149b60a25f3c4dc7

parser/auth.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,20 @@ func authWhoami(argv []string) error {
169169
usage := `
170170
Displays the currently logged in user.
171171
172-
Usage: deis auth:whoami
172+
Usage: deis auth:whoami [options]
173+
174+
Options:
175+
--all
176+
fetch a more detailed description about the user.
173177
`
174178

175-
if _, err := docopt.Parse(usage, argv, true, "", false, true); err != nil {
179+
args, err := docopt.Parse(usage, argv, true, "", false, true)
180+
181+
if err != nil {
176182
return err
177183
}
178184

179-
return cmd.Whoami()
185+
return cmd.Whoami(args["--all"].(bool))
180186
}
181187

182188
func authCancel(argv []string) error {

0 commit comments

Comments
 (0)