1
0
mirror of https://gitea.com/Sirherobrine23/tea.git synced 2024-07-07 10:26:21 -03:00
tea/modules/print/login.go
6543 5cb3e1ded5 Refactor: Move list print functions into print package (#273)
MV list issues -> print.IssuesList

MV list labels -> print.LabelsList & task.LabelsExport

MV list logins -> print.LoginsList

MV list miles -> print.MilestonesList

MV list pulls -> print.PullsList

MV list releases -> print.ReleasesList

MV list issues&pulls of mile -> print.IssuesPullsList

MV list notification threads -> print.NotificationsList

Unexport print.outputList

Unexport print.outputMarkdown

remove comd/flags dependency in print module

Reviewed-on: https://gitea.com/gitea/tea/pulls/273
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-Authored-By: 6543 <6543@obermui.de>
Co-Committed-By: 6543 <6543@obermui.de>
2020-12-08 18:28:54 +08:00

57 lines
1.1 KiB
Go

// 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 print
import (
"fmt"
"strings"
"time"
"code.gitea.io/tea/modules/config"
)
// LoginDetails print login entry to stdout
func LoginDetails(login *config.Login, output string) {
in := fmt.Sprintf("# %s\n\n[@%s](%s/%s)\n",
login.Name,
login.User,
strings.TrimSuffix(login.URL, "/"),
login.User,
)
if len(login.SSHKey) != 0 {
in += fmt.Sprintf("\nSSH Key: '%s' via %s\n",
login.SSHKey,
login.SSHHost,
)
}
in += fmt.Sprintf("\nCreated: %s", time.Unix(login.Created, 0).Format(time.RFC822))
outputMarkdown(in)
}
// LoginsList prints a listing of logins
func LoginsList(logins []config.Login, output string) {
var values [][]string
headers := []string{
"Name",
"URL",
"SSHHost",
"User",
"Default",
}
for _, l := range logins {
values = append(values, []string{
l.Name,
l.URL,
l.GetSSHHost(),
l.User,
fmt.Sprint(l.Default),
})
}
outputList(output, headers, values)
}