Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
feature: add --user flag to secman whoami command to display user
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Mar 18, 2022
1 parent 685c19b commit 64f1752
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ var GenOpts = options.GenOptions{
var AuthOpts = options.AuthOptions{
ConfirmLogout: false,
}

var WhoamiOpts = options.WhoamiOptions{
ShowUser: false,
}
8 changes: 7 additions & 1 deletion app/whoami.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ func WhoamiCMD() *cobra.Command {
primary := lipgloss.NewStyle().Foreground(lipgloss.Color(constants.PRIMARY_COLOR))
bold := lipgloss.NewStyle().Bold(true)

fmt.Println(s.Render("\n👊 Hi ") + primary.Render(config.Config("config.name")) + " <" + bold.Render(config.Config("config.user")) + ">")
if WhoamiOpts.ShowUser {
fmt.Println(config.Config("config.name"))
} else {
fmt.Println(s.Render("\n👊 Hi ") + primary.Render(config.Config("config.name")) + " <" + bold.Render(config.Config("config.user")) + ">")
}

return nil
},
}

cmd.Flags().BoolVarP(&WhoamiOpts.ShowUser, "user", "u", false, "Just Display the username")

return cmd
}
4 changes: 4 additions & 0 deletions pkg/options/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ type AuthOptions struct {
type RootOptions struct {
Version bool
}

type WhoamiOptions struct {
ShowUser bool
}

0 comments on commit 64f1752

Please sign in to comment.