2020-09-30 01:11:33 -04: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-16 11:47:40 -05:00
|
|
|
Name: "list",
|
|
|
|
Aliases: []string{"ls"},
|
2020-09-30 01:11:33 -04:00
|
|
|
Usage: "List Gitea logins",
|
|
|
|
Description: `List Gitea logins`,
|
2022-09-13 14:14:02 -04:00
|
|
|
ArgsUsage: " ", // command does not accept arguments
|
2020-10-02 11:57:48 -04:00
|
|
|
Action: RunLoginList,
|
2020-09-30 01:11:33 -04:00
|
|
|
Flags: []cli.Flag{&flags.OutputFlag},
|
|
|
|
}
|
|
|
|
|
2020-10-02 11:57:48 -04:00
|
|
|
// RunLoginList list all logins
|
2020-12-15 12:38:22 -05:00
|
|
|
func RunLoginList(cmd *cli.Context) error {
|
2020-12-12 08:28:37 -05:00
|
|
|
logins, err := config.GetLogins()
|
2020-09-30 01:11:33 -04:00
|
|
|
if err != nil {
|
2020-12-16 11:18:10 -05:00
|
|
|
return err
|
2020-09-30 01:11:33 -04:00
|
|
|
}
|
2020-12-15 12:38:22 -05:00
|
|
|
print.LoginsList(logins, cmd.String("output"))
|
2020-09-30 01:11:33 -04:00
|
|
|
return nil
|
|
|
|
}
|