diff --git a/config.yml b/config.yml index b7c6f84a..d504aad5 100644 --- a/config.yml +++ b/config.yml @@ -40,7 +40,7 @@ wtf: repository: "/Users/chris/go/src/github.com/senorprogrammer/wtf" github: enabled: true - organization: "BetterOfficeApps" + owner: "BetterOfficeApps" position: top: 2 left: 2 diff --git a/github/client.go b/github/client.go index 4af4e282..33fd5adc 100644 --- a/github/client.go +++ b/github/client.go @@ -21,13 +21,13 @@ func NewClient() *Client { return &client } -func (client *Client) PullRequests(orgName string, repoName string) ([]*ghb.PullRequest, error) { +func (client *Client) PullRequests(owner string, repoName string) ([]*ghb.PullRequest, error) { oauthClient := client.oauthClient() github := ghb.NewClient(oauthClient) opts := &ghb.PullRequestListOptions{} - prs, _, err := github.PullRequests.List(context.Background(), orgName, repoName, opts) + prs, _, err := github.PullRequests.List(context.Background(), owner, repoName, opts) if err != nil { return nil, err @@ -36,11 +36,11 @@ func (client *Client) PullRequests(orgName string, repoName string) ([]*ghb.Pull return prs, nil } -func (client *Client) Repository(orgName string, repoName string) (*ghb.Repository, error) { +func (client *Client) Repository(owner string, repoName string) (*ghb.Repository, error) { oauthClient := client.oauthClient() github := ghb.NewClient(oauthClient) - repo, _, err := github.Repositories.Get(context.Background(), orgName, repoName) + repo, _, err := github.Repositories.Get(context.Background(), owner, repoName) if err != nil { return nil, err diff --git a/github/widget.go b/github/widget.go index ec7369d2..0a07603a 100644 --- a/github/widget.go +++ b/github/widget.go @@ -35,15 +35,9 @@ func (widget *Widget) Refresh() { } client := NewClient() + prs, _ := client.PullRequests(Config.UString("wtf.github.owner"), Config.UString("wtf.github.repo")) - repo, _ := client.Repository(Config.UString("wtf.github.organization"), Config.UString("wtf.github.repo")) - org := *repo.Organization - - prs, _ := client.PullRequests(Config.UString("wtf.github.organization"), Config.UString("wtf.github.repo")) - - title := fmt.Sprintf("[green]%s - %s[white]", *org.Login, *repo.Name) - - widget.View.SetTitle(fmt.Sprintf(" Github: %s ", title)) + widget.View.SetTitle(fmt.Sprintf(" Github: %s ", widget.title())) widget.RefreshedAt = time.Now() str := " [red]Open Review Requests[white]\n" @@ -113,3 +107,7 @@ func (widget *Widget) openPRs(prs []*ghb.PullRequest) string { return " [grey]none[white]\n" } + +func (widget *Widget) title() string { + return fmt.Sprintf("[green]%s - %s[white]", Config.UString("wtf.github.owner"), Config.UString("wtf.github.repo")) +} diff --git a/wtf.go b/wtf.go index adfd7783..c0fb762d 100644 --- a/wtf.go +++ b/wtf.go @@ -57,6 +57,12 @@ var Config = wtf.LoadConfigFile() func main() { wtf.Config = Config + // Grid stores all the widgets onscreen (like an HTML table) + grid := tview.NewGrid() + grid.SetColumns(wtf.ToInts(Config.UList("wtf.grid.columns"))...) + grid.SetRows(wtf.ToInts(Config.UList("wtf.grid.rows"))...) + grid.SetBorder(false) + // TODO: Really need to generalize all of these. This don't scale bamboohr.Config = Config bamboo := bamboohr.NewWidget() @@ -98,11 +104,6 @@ func main() { weather := weather.NewWidget() go wtf.Schedule(weather) - grid := tview.NewGrid() - grid.SetColumns(wtf.ToInts(Config.UList("wtf.grid.columns"))...) - grid.SetRows(wtf.ToInts(Config.UList("wtf.grid.rows"))...) - grid.SetBorder(false) - addToApp(grid, bamboo) addToApp(grid, cal) addToApp(grid, git)