mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-07 04:12:55 +02:00
Add Detail View for Login (#212)
Impruve & Refactor AddLogin Impruve login comands Remove unused Package + Vars Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/212 Reviewed-by: Norwin <noerw@noreply.gitea.io> Reviewed-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
29
cmd/login.go
29
cmd/login.go
@ -5,7 +5,11 @@
|
||||
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"
|
||||
)
|
||||
@ -16,7 +20,8 @@ var CmdLogin = cli.Command{
|
||||
Aliases: []string{"login"},
|
||||
Usage: "Log in to a Gitea server",
|
||||
Description: `Log in to a Gitea server`,
|
||||
Action: login.RunLoginAddInteractive, // TODO show list if no arg & detail if login as arg
|
||||
ArgsUsage: "[<login name>]",
|
||||
Action: runLogins,
|
||||
Subcommands: []*cli.Command{
|
||||
&login.CmdLoginList,
|
||||
&login.CmdLoginAdd,
|
||||
@ -24,3 +29,25 @@ var CmdLogin = cli.Command{
|
||||
&login.CmdLoginSetDefault,
|
||||
},
|
||||
}
|
||||
|
||||
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 {
|
||||
if err := config.LoadConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
l := config.GetLoginByName(name)
|
||||
if l == nil {
|
||||
fmt.Printf("Login '%s' do not exist\n\n", name)
|
||||
return nil
|
||||
}
|
||||
|
||||
print.LoginDetails(l)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user