2016-05-06 17:59:36 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"text/template"
|
|
|
|
|
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()
|
|
|
|
owner, name, err := parseRepo(arg)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
client, err := 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 }}
|
|
|
|
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 }}
|
|
|
|
`
|