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