~w1ke/hut

37a4cb0310abef3035085f9c080413301caf682d — w1ke 11 months ago 9a465da
added count flag to g repo
2 files changed, 15 insertions(+), 3 deletions(-)

M api/git/git.go
M cmd/hut/git.go
M api/git/git.go => api/git/git.go +9 -2
@@ 85,7 85,7 @@ type RepositoryCursor struct {
	Results []Repository
}

func (c *Client) Repo(identificator string) error {
func (c *Client) Repo(identificator string, count int) error {
	if identificator == "" {
		// list logged in user's repos
		var query struct {


@@ 108,12 108,19 @@ func (c *Client) Repo(identificator string) error {

		var query struct {
			User struct {
				Repositories RepositoryCursor
				Repositories RepositoryCursor `graphql:"repositories(filter: $filter)"`
			} `graphql:"user(username: $username)"`
		}

		type Filter struct {
			Count graphql.Int `json:"count"`
		}

		variables := map[string]interface{}{
			"username": graphql.String(identificator),
			"filter": Filter{
				Count: graphql.Int(count),
			},
		}

		err := c.graphql.Query(context.Background(), &query, variables)

M cmd/hut/git.go => cmd/hut/git.go +6 -1
@@ 52,7 52,12 @@ func gitRoot(args []string) {
		if len(args) >= 2 {
			identificator = args[1]
		}
		err := client.Repo(identificator)
		flagSet := flag.NewFlagSet("hut git repo", flag.ExitOnError)
		var (
			count = flagSet.Int("count", 10, "maximum number of repos listed")
		)
		flagSet.Parse(args[2:])
		err := client.Repo(identificator, *count)
		if err != nil {
			log.Fatal(err)
		}