2020-09-30 13:11:33 +08:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
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-17 00:47:40 +08:00
|
|
|
Name: "list",
|
|
|
|
Aliases: []string{"ls"},
|
2020-09-30 13:11:33 +08:00
|
|
|
Usage: "List Gitea logins",
|
|
|
|
Description: `List Gitea logins`,
|
2020-10-02 23:57:48 +08:00
|
|
|
Action: RunLoginList,
|
2020-09-30 13:11:33 +08:00
|
|
|
Flags: []cli.Flag{&flags.OutputFlag},
|
|
|
|
}
|
|
|
|
|
2020-10-02 23:57:48 +08:00
|
|
|
// RunLoginList list all logins
|
2020-12-16 01:38:22 +08:00
|
|
|
func RunLoginList(cmd *cli.Context) error {
|
2020-12-12 21:28:37 +08:00
|
|
|
logins, err := config.GetLogins()
|
2020-09-30 13:11:33 +08:00
|
|
|
if err != nil {
|
2020-12-17 00:18:10 +08:00
|
|
|
return err
|
2020-09-30 13:11:33 +08:00
|
|
|
}
|
2020-12-16 01:38:22 +08:00
|
|
|
print.LoginsList(logins, cmd.String("output"))
|
2020-09-30 13:11:33 +08:00
|
|
|
return nil
|
|
|
|
}
|