mirror of
https://gitea.com/gitea/tea.git
synced 2024-11-25 12:01:36 +01:00
6ea331ce3b
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>
55 lines
1.2 KiB
Go
55 lines
1.2 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 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"},
|
|
Required: false,
|
|
Usage: "Filter by type: fork, mirror, source",
|
|
}
|
|
|
|
func getTypeFilter(ctx *cli.Context) (filter gitea.RepoType, err error) {
|
|
t := ctx.String("type")
|
|
filter = gitea.RepoTypeNone
|
|
switch t {
|
|
case "":
|
|
filter = gitea.RepoTypeNone
|
|
case "fork":
|
|
filter = gitea.RepoTypeFork
|
|
case "mirror":
|
|
filter = gitea.RepoTypeMirror
|
|
case "source":
|
|
filter = gitea.RepoTypeSource
|
|
default:
|
|
err = fmt.Errorf("invalid repo type '%s'. valid: fork, mirror, source", t)
|
|
}
|
|
return
|
|
}
|