2019-04-06 21:32:14 +02:00
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"text/template"
|
|
|
|
|
2021-10-27 21:03:14 +02:00
|
|
|
"github.com/urfave/cli/v2"
|
2021-10-12 09:25:13 +02:00
|
|
|
|
2021-10-27 21:03:14 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/common"
|
2021-09-21 16:36:41 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
2019-04-06 21:32:14 +02:00
|
|
|
)
|
|
|
|
|
2021-10-27 21:03:14 +02:00
|
|
|
var repoInfoCmd = &cli.Command{
|
2019-04-06 21:32:14 +02:00
|
|
|
Name: "info",
|
|
|
|
Usage: "show repository details",
|
|
|
|
ArgsUsage: "<repo/name>",
|
|
|
|
Action: repoInfo,
|
2021-10-27 21:03:14 +02:00
|
|
|
Flags: append(common.GlobalFlags,
|
|
|
|
common.FormatFlag(tmplRepoInfo),
|
|
|
|
),
|
2019-04-06 21:32:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func repoInfo(c *cli.Context) error {
|
|
|
|
arg := c.Args().First()
|
|
|
|
owner, name, err := internal.ParseRepo(arg)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
client, err := internal.NewClient(c)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
repo, err := client.Repo(owner, name)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpl, err := template.New("_").Parse(c.String("format"))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return tmpl.Execute(os.Stdout, repo)
|
|
|
|
}
|
|
|
|
|
|
|
|
// template for repo information
|
|
|
|
var tmplRepoInfo = `Owner: {{ .Owner }}
|
|
|
|
Repo: {{ .Name }}
|
2022-11-02 19:02:41 +02:00
|
|
|
Type: {{ .Kind }}
|
2019-04-06 21:32:14 +02:00
|
|
|
Config: {{ .Config }}
|
|
|
|
Visibility: {{ .Visibility }}
|
2021-11-22 13:55:13 +02:00
|
|
|
Private: {{ .IsSCMPrivate }}
|
2019-04-06 21:32:14 +02:00
|
|
|
Trusted: {{ .IsTrusted }}
|
|
|
|
Gated: {{ .IsGated }}
|
2022-11-05 01:35:06 +02:00
|
|
|
Forge: {{ .Clone }}
|
2019-04-06 21:32:14 +02:00
|
|
|
`
|