2020-09-30 07:11:33 +02:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2023-09-08 03:40:02 +02:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-09-30 07:11:33 +02:00
|
|
|
|
|
|
|
package login
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/tea/cmd/flags"
|
|
|
|
"code.gitea.io/tea/modules/config"
|
|
|
|
"code.gitea.io/tea/modules/print"
|
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CmdLoginList represents to login a gitea server.
|
|
|
|
var CmdLoginList = cli.Command{
|
2020-12-16 17:47:40 +01:00
|
|
|
Name: "list",
|
|
|
|
Aliases: []string{"ls"},
|
2020-09-30 07:11:33 +02:00
|
|
|
Usage: "List Gitea logins",
|
|
|
|
Description: `List Gitea logins`,
|
2022-09-13 20:14:02 +02:00
|
|
|
ArgsUsage: " ", // command does not accept arguments
|
2020-10-02 17:57:48 +02:00
|
|
|
Action: RunLoginList,
|
2020-09-30 07:11:33 +02:00
|
|
|
Flags: []cli.Flag{&flags.OutputFlag},
|
|
|
|
}
|
|
|
|
|
2020-10-02 17:57:48 +02:00
|
|
|
// RunLoginList list all logins
|
2020-12-15 18:38:22 +01:00
|
|
|
func RunLoginList(cmd *cli.Context) error {
|
2020-12-12 14:28:37 +01:00
|
|
|
logins, err := config.GetLogins()
|
2020-09-30 07:11:33 +02:00
|
|
|
if err != nil {
|
2020-12-16 17:18:10 +01:00
|
|
|
return err
|
2020-09-30 07:11:33 +02:00
|
|
|
}
|
2020-12-15 18:38:22 +01:00
|
|
|
print.LoginsList(logins, cmd.String("output"))
|
2020-09-30 07:11:33 +02:00
|
|
|
return nil
|
|
|
|
}
|