2017-04-29 17:03:45 +00:00
|
|
|
package repo
|
2016-05-06 17:59:36 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"text/template"
|
|
|
|
|
2017-04-29 17:03:45 +00:00
|
|
|
"github.com/drone/drone/drone/internal"
|
2017-03-16 10:14:02 +00:00
|
|
|
"github.com/urfave/cli"
|
2016-05-06 17:59:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var repoInfoCmd = cli.Command{
|
2017-03-16 10:14:02 +00:00
|
|
|
Name: "info",
|
|
|
|
Usage: "show repository details",
|
|
|
|
Action: repoInfo,
|
2016-05-06 17:59:36 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "format",
|
|
|
|
Usage: "format output",
|
|
|
|
Value: tmplRepoInfo,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func repoInfo(c *cli.Context) error {
|
|
|
|
arg := c.Args().First()
|
2017-04-29 17:03:45 +00:00
|
|
|
owner, name, err := internal.ParseRepo(arg)
|
2016-05-06 17:59:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-04-29 17:03:45 +00:00
|
|
|
client, err := internal.NewClient(c)
|
2016-05-06 17:59:36 +00:00
|
|
|
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 }}
|
|
|
|
Type: {{ .Kind }}
|
2017-04-12 12:12:21 +00:00
|
|
|
Config: {{ .Config }}
|
2016-05-06 17:59:36 +00:00
|
|
|
Private: {{ .IsPrivate }}
|
2017-04-12 12:12:21 +00:00
|
|
|
Trusted: {{ .IsTrusted }}
|
|
|
|
Gated: {{ .IsGated }}
|
2016-05-06 17:59:36 +00:00
|
|
|
Remote: {{ .Clone }}
|
|
|
|
`
|