Skip to content

Commit

Permalink
Fix bun about -m option from 0120327
Browse files Browse the repository at this point in the history
  • Loading branch information
sona-tar committed Dec 29, 2015
1 parent 4579505 commit 70a99e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 5 additions & 1 deletion ghs.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func main() {
select {
case repo.repos = <-reposBuff:
Debug("print\n")
repo.PrintRepository()
end := repo.PrintRepository()
if end {
Debug("over max\n")
return
}
case <-fin:
Debug("fin\n")
return
Expand Down
20 changes: 14 additions & 6 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import (
)

type repo struct {
client *github.Client
opts *github.SearchOptions
query string
repos []github.Repository
client *github.Client
opts *github.SearchOptions
query string
repos []github.Repository
printMax int
printCount int
}

func getToken(optsToken string) string {
Expand Down Expand Up @@ -75,7 +77,7 @@ func NewRepo(sort string, order string, max int, enterprise string, token string
ListOptions: github.ListOptions{PerPage: 100},
}

return &repo{client: cli, opts: searchOpts, query: query}, nil
return &repo{client: cli, opts: searchOpts, query: query, printMax: max}, nil
}

func (r repo) search() (repos []github.Repository) {
Expand Down Expand Up @@ -126,7 +128,7 @@ func (r repo) SearchRepository() (<-chan []github.Repository, <-chan bool) {
return reposBuff, fin
}

func (r repo) PrintRepository() {
func (r repo) PrintRepository() (end bool) {
Debug("%d\n", len(r.repos))
repoNameMaxLen := 0
for _, repo := range r.repos {
Expand All @@ -153,5 +155,11 @@ func (r repo) PrintRepository() {
}

fmt.Printf("\n")
r.printCount++
if r.printCount >= r.printMax {
return true
}

}
return false
}

0 comments on commit 70a99e9

Please sign in to comment.