Skip to content

Commit e443606

Browse files
author
Stephen Gutekanst
committed
cmd/src: add src repos list -names-without-host flag
1 parent 12da1c7 commit e443606

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

cmd/src/repos_list.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"strings"
67
)
78

89
func init() {
@@ -41,16 +42,17 @@ Examples:
4142
firstFlag = flagSet.Int("first", 1000, "Returns the first n repositories from the list. (use -1 for unlimited)")
4243
queryFlag = flagSet.String("query", "", `Returns repositories whose names match the query. (e.g. "myorg/")`)
4344
// TODO: add support for "names" field.
44-
enabledFlag = flagSet.Bool("enabled", true, "Include enabled repositories.")
45-
disabledFlag = flagSet.Bool("disabled", false, "Include disabled repositories.")
46-
clonedFlag = flagSet.Bool("cloned", true, "Include cloned repositories.")
47-
cloneInProgressFlag = flagSet.Bool("clone-in-progress", true, "Include repositories that are currently being cloned.")
48-
notClonedFlag = flagSet.Bool("not-cloned", true, "Include repositories that are not yet cloned and for which cloning is not in progress.")
49-
indexedFlag = flagSet.Bool("indexed", true, "Include repositories that have a text search index.")
50-
notIndexedFlag = flagSet.Bool("not-indexed", true, "Include repositories that do not have a text search index.")
51-
orderByFlag = flagSet.String("order-by", "name", `How to order the results; possible choices are: "name", "created-at"`)
52-
descendingFlag = flagSet.Bool("descending", false, "Whether or not results should be in descending order.")
53-
apiFlags = newAPIFlags(flagSet)
45+
enabledFlag = flagSet.Bool("enabled", true, "Include enabled repositories.")
46+
disabledFlag = flagSet.Bool("disabled", false, "Include disabled repositories.")
47+
clonedFlag = flagSet.Bool("cloned", true, "Include cloned repositories.")
48+
cloneInProgressFlag = flagSet.Bool("clone-in-progress", true, "Include repositories that are currently being cloned.")
49+
notClonedFlag = flagSet.Bool("not-cloned", true, "Include repositories that are not yet cloned and for which cloning is not in progress.")
50+
indexedFlag = flagSet.Bool("indexed", true, "Include repositories that have a text search index.")
51+
notIndexedFlag = flagSet.Bool("not-indexed", true, "Include repositories that do not have a text search index.")
52+
orderByFlag = flagSet.String("order-by", "name", `How to order the results; possible choices are: "name", "created-at"`)
53+
descendingFlag = flagSet.Bool("descending", false, "Whether or not results should be in descending order.")
54+
namesWithoutHostFlag = flagSet.Bool("names-without-host", false, "Whether or not repository names should be printed without the code host (new form)")
55+
apiFlags = newAPIFlags(flagSet)
5456
)
5557

5658
handler := func(args []string) error {
@@ -123,6 +125,11 @@ Examples:
123125
result: &result,
124126
done: func() error {
125127
for _, repo := range result.Repositories.Nodes {
128+
if *namesWithoutHostFlag {
129+
firstSlash := strings.Index(repo.Name, "/")
130+
fmt.Println(repo.Name[firstSlash+len("/"):])
131+
continue
132+
}
126133
fmt.Println(repo.Name)
127134
}
128135
return nil

0 commit comments

Comments
 (0)