mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 18:08:30 +02:00
improve formatting of tea repos
(#223)
make fmt code review use OutputMarkdown use FormatTime() improved repo printing - ReposList() now allows selection of fields - RepoDetail() uses glamour and provides more details Co-authored-by: Norwin Roosen <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/223 Reviewed-by: 6543 <6543@noreply.gitea.io> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-Authored-By: Norwin <noerw@noreply.gitea.io> Co-Committed-By: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
@ -6,11 +6,28 @@ package repos
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/tea/modules/print"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// printFieldsFlag provides a selection of fields to print
|
||||
var printFieldsFlag = cli.StringFlag{
|
||||
Name: "fields",
|
||||
Aliases: []string{"f"},
|
||||
Usage: fmt.Sprintf(`Comma-separated list of fields to print. Available values:
|
||||
%s
|
||||
`, strings.Join(print.RepoFields, ",")),
|
||||
Value: "owner,name,type,ssh",
|
||||
}
|
||||
|
||||
func getFields(ctx *cli.Context) []string {
|
||||
return strings.Split(ctx.String("fields"), ",")
|
||||
}
|
||||
|
||||
var typeFilterFlag = cli.StringFlag{
|
||||
Name: "type",
|
||||
Aliases: []string{"T"},
|
||||
|
@ -27,6 +27,7 @@ var CmdReposListFlags = append([]cli.Flag{
|
||||
Required: false,
|
||||
Usage: "List your starred repos instead",
|
||||
},
|
||||
&printFieldsFlag,
|
||||
&typeFilterFlag,
|
||||
&flags.PaginationPageFlag,
|
||||
&flags.PaginationLimitFlag,
|
||||
@ -79,7 +80,7 @@ func RunReposList(ctx *cli.Context) error {
|
||||
reposFiltered = filterReposByType(rps, typeFilter)
|
||||
}
|
||||
|
||||
print.ReposList(reposFiltered)
|
||||
print.ReposList(reposFiltered, getFields(ctx))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ var CmdReposSearch = cli.Command{
|
||||
Required: false,
|
||||
Usage: "Filter archived repos (true|false)",
|
||||
},
|
||||
&printFieldsFlag,
|
||||
&flags.PaginationPageFlag,
|
||||
&flags.PaginationLimitFlag,
|
||||
}, flags.LoginOutputFlags...),
|
||||
@ -122,6 +123,6 @@ func runReposSearch(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
print.ReposList(rps)
|
||||
print.ReposList(rps, getFields(ctx))
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user