2021-10-04 13:41:59 -04:00
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
2023-09-07 21:40:02 -04:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-10-04 13:41:59 -04:00
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/tea/modules/context"
|
|
|
|
"code.gitea.io/tea/modules/print"
|
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CmdWhoami represents the command to show current logged in user
|
|
|
|
var CmdWhoami = cli.Command{
|
|
|
|
Name: "whoami",
|
2022-09-13 15:49:34 -04:00
|
|
|
Category: catMisc,
|
2021-10-04 13:41:59 -04:00
|
|
|
Description: `For debugging purposes, show the user that is currently logged in.`,
|
|
|
|
Usage: "Show current logged in user",
|
2022-09-13 14:14:02 -04:00
|
|
|
ArgsUsage: " ", // command does not accept arguments
|
2021-10-04 13:41:59 -04:00
|
|
|
Action: func(cmd *cli.Context) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
client := ctx.Login.Client()
|
|
|
|
user, _, _ := client.GetMyUserInfo()
|
|
|
|
print.UserDetails(user)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|