Browse Source

Add a "--repos" flag to "bashbrew list" to prefer to list only repos

Tianon Gravi 9 years ago
parent
commit
1bf47856f0
2 changed files with 16 additions and 0 deletions
  1. 12 0
      bashbrew/go/src/bashbrew/cmd-list.go
  2. 4 0
      bashbrew/go/src/bashbrew/main.go

+ 12 - 0
bashbrew/go/src/bashbrew/cmd-list.go

@@ -24,6 +24,7 @@ func cmdList(c *cli.Context) error {
 	uniq := c.Bool("uniq")
 	namespace := ""
 	applyConstraints := c.Bool("apply-constraints")
+	onlyRepos := c.Bool("repos")
 
 	for _, repo := range repos {
 		r, err := fetch(repo)
@@ -31,6 +32,17 @@ func cmdList(c *cli.Context) error {
 			return cli.NewMultiError(fmt.Errorf(`failed fetching repo %q`, repo), err)
 		}
 
+		if onlyRepos {
+			if r.TagEntry == nil {
+				fmt.Printf("%s\n", r.RepoName)
+			} else {
+				for _, tag := range r.Tags(namespace, uniq, *r.TagEntry) {
+					fmt.Printf("%s\n", tag)
+				}
+			}
+			continue
+		}
+
 		var entries []manifest.Manifest2822Entry
 		if buildOrder {
 			entries, err = r.SortedEntries()

+ 4 - 0
bashbrew/go/src/bashbrew/main.go

@@ -252,6 +252,10 @@ func main() {
 					Name:  "apply-constraints",
 					Usage: "apply Constraints as if repos were building",
 				},
+				cli.BoolFlag{
+					Name:  "repos",
+					Usage: `list only repos, not repo:tag (unless "repo:tag" is explicitly specified)`,
+				},
 			},
 			Before: subcommandBeforeFactory("list"),
 			Action: cmdList,