Skip to content

Commit

Permalink
Cleaner init for GitHubFetcher in app
Browse files Browse the repository at this point in the history
  • Loading branch information
pengwynn committed Dec 9, 2014
1 parent e35708a commit e3c9653
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 2 additions & 7 deletions flint/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package flint

import (
"github.com/codegangsta/cli"
"github.com/octokit/go-octokit/octokit"

"fmt"
"os"
Expand Down Expand Up @@ -98,14 +97,10 @@ func newFlagsFromContext(c *cli.Context) *Flags {
}

var newGitHubFetcher = func(c *cli.Context) RemoteRepositoryFetcher {
var client *octokit.Client

token := c.String("token")
if len(token) > 0 {
client = octokit.NewClient(octokit.TokenAuth{AccessToken: token})
return NewGitHubFetcherWithToken(token)
} else {
client = octokit.NewClient(nil)
return NewGitHubFetcher()
}

return &GitHubFetcher{client}
}
6 changes: 6 additions & 0 deletions flint/github_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func (g *GitHubFetcher) ParseFullName(nwo string) (owner, name string, err error
return
}

func NewGitHubFetcher() *GitHubFetcher {
client := octokit.NewClient(nil)

return &GitHubFetcher{&*client}
}

func NewGitHubFetcherWithToken(token string) *GitHubFetcher {
client := octokit.NewClient(&octokit.TokenAuth{AccessToken: token})

Expand Down

0 comments on commit e3c9653

Please sign in to comment.