2020-09-30 05:11:33 +00: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 (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"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{
|
|
|
|
Name: "ls",
|
2020-10-02 15:46:51 +00:00
|
|
|
Aliases: []string{"list"},
|
2020-09-30 05:11:33 +00:00
|
|
|
Usage: "List Gitea logins",
|
|
|
|
Description: `List Gitea logins`,
|
2020-10-02 15:57:48 +00:00
|
|
|
Action: RunLoginList,
|
2020-09-30 05:11:33 +00:00
|
|
|
Flags: []cli.Flag{&flags.OutputFlag},
|
|
|
|
}
|
|
|
|
|
2020-10-02 15:57:48 +00:00
|
|
|
// RunLoginList list all logins
|
2020-12-15 17:38:22 +00:00
|
|
|
func RunLoginList(cmd *cli.Context) error {
|
2020-12-12 13:28:37 +00:00
|
|
|
logins, err := config.GetLogins()
|
2020-09-30 05:11:33 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2020-12-15 17:38:22 +00:00
|
|
|
print.LoginsList(logins, cmd.String("output"))
|
2020-09-30 05:11:33 +00:00
|
|
|
return nil
|
|
|
|
}
|