2020-09-30 07:11:33 +02: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 17:46:51 +02:00
|
|
|
Aliases: []string{"list"},
|
2020-09-30 07:11:33 +02:00
|
|
|
Usage: "List Gitea logins",
|
|
|
|
Description: `List Gitea logins`,
|
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 {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2020-12-15 18:38:22 +01:00
|
|
|
print.LoginsList(logins, cmd.String("output"))
|
2020-09-30 07:11:33 +02:00
|
|
|
return nil
|
|
|
|
}
|