2021-10-04 17:41:59 +00:00
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
2023-09-08 01:40:02 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-10-04 17:41:59 +00: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 19:49:34 +00:00
|
|
|
Category: catMisc,
|
2021-10-04 17:41:59 +00:00
|
|
|
Description: `For debugging purposes, show the user that is currently logged in.`,
|
|
|
|
Usage: "Show current logged in user",
|
2022-09-13 18:14:02 +00:00
|
|
|
ArgsUsage: " ", // command does not accept arguments
|
2021-10-04 17:41:59 +00:00
|
|
|
Action: func(cmd *cli.Context) error {
|
|
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
client := ctx.Login.Client()
|
|
|
|
user, _, _ := client.GetMyUserInfo()
|
|
|
|
print.UserDetails(user)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|