forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhoami.go
More file actions
32 lines (25 loc) · 715 Bytes
/
Copy pathwhoami.go
File metadata and controls
32 lines (25 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cmd
import (
"context"
"fmt"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/ui"
)
func (h *Handler) Whoami(ctx context.Context, req *entity.CommandRequest) error {
user, err := h.ctrl.GetUser(ctx)
if err != nil {
return err
}
userText := fmt.Sprintf("%s", ui.MagentaText(user.Email))
if user.Name != "" {
userText = fmt.Sprintf("%s (%s)", user.Name, ui.MagentaText(user.Email))
}
project, projectError := h.ctrl.GetCurrentProject(ctx)
projectText := ""
if projectError == nil {
projectText = fmt.Sprintf("Current Project Id: %s\n", ui.MagentaText(project.Id))
}
fmt.Printf("👋 Hey %s\n%s", userText, projectText)
// Todo, more info, also more fun
return nil
}