[Refactor] unexport config.Config var & move login tasks to task module (#288)

Unexport generateToken()

move CreateLogin into task

Create func config.SetDefaultLogin()

Unexport loadConfig() & saveConfig

unexport config var

make SetDefaultLogin() case insensitive

update func descriptions

move FindSSHKey to task module

Reviewed-on: https://gitea.com/gitea/tea/pulls/288
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-Authored-By: 6543 <6543@obermui.de>
Co-Committed-By: 6543 <6543@obermui.de>
This commit is contained in:
6543
2020-12-12 21:28:37 +08:00
parent eeb9cbafe7
commit c063329e9a
12 changed files with 226 additions and 175 deletions

View File

@ -29,7 +29,7 @@ var CmdLogout = cli.Command{
}
func runLogout(ctx *cli.Context) error {
err := config.LoadConfig()
logins, err := config.GetLogins()
if err != nil {
log.Fatal(err)
}
@ -40,8 +40,8 @@ func runLogout(ctx *cli.Context) error {
name = ctx.String("name")
} else if len(ctx.Args().First()) != 0 {
name = ctx.Args().First()
} else if len(config.Config.Logins) == 1 {
name = config.Config.Logins[0].Name
} else if len(logins) == 1 {
name = logins[0].Name
} else {
return errors.New("Please specify a login name")
}