mirror of
https://gitea.com/gitea/tea.git
synced 2024-11-03 04:27:21 -05:00
2984ad4964
Add support to tea login with helper same another tools and `gh` Reviewed-on: https://gitea.com/gitea/tea/pulls/612 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com> Co-committed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.gitea.io/tea/cmd/login"
|
|
"code.gitea.io/tea/modules/config"
|
|
"code.gitea.io/tea/modules/print"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// CmdLogin represents to login a gitea server.
|
|
var CmdLogin = cli.Command{
|
|
Name: "logins",
|
|
Aliases: []string{"login"},
|
|
Category: catSetup,
|
|
Usage: "Log in to a Gitea server",
|
|
Description: `Log in to a Gitea server`,
|
|
ArgsUsage: "[<login name>]",
|
|
Action: runLogins,
|
|
Subcommands: []*cli.Command{
|
|
&login.CmdLoginList,
|
|
&login.CmdLoginAdd,
|
|
&login.CmdLoginEdit,
|
|
&login.CmdLoginDelete,
|
|
&login.CmdLoginSetDefault,
|
|
&login.CmdLoginHelper,
|
|
},
|
|
}
|
|
|
|
func runLogins(ctx *cli.Context) error {
|
|
if ctx.Args().Len() == 1 {
|
|
return runLoginDetail(ctx.Args().First())
|
|
}
|
|
return login.RunLoginList(ctx)
|
|
}
|
|
|
|
func runLoginDetail(name string) error {
|
|
l := config.GetLoginByName(name)
|
|
if l == nil {
|
|
fmt.Printf("Login '%s' do not exist\n\n", name)
|
|
return nil
|
|
}
|
|
|
|
print.LoginDetails(l)
|
|
return nil
|
|
}
|