1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'master' of github.com:mryanmurphy/wtf into mryanmurphy-master

This commit is contained in:
Chris Cummer 2020-05-26 21:25:11 -07:00
commit 92285b194f
2 changed files with 31 additions and 19 deletions

View File

@ -33,13 +33,19 @@ func (widget *Widget) content() (string, string, bool) {
} }
_, _, width, _ := widget.View.GetRect() _, _, width, _ := widget.View.GetRect()
str := widget.settings.common.SigilStr(len(widget.GithubRepos), widget.Idx, width) + "\n" str := widget.settings.common.SigilStr(len(widget.GithubRepos), widget.Idx, width)
str += fmt.Sprintf(" [%s]Stats[white]\n", widget.settings.common.Colors.Subheading) if widget.settings.showStats {
str += widget.displayStats(repo) str += fmt.Sprintf("\n [%s]Stats[white]\n", widget.settings.common.Colors.Subheading)
str += fmt.Sprintf("\n [%s]Open Review Requests[white]\n", widget.settings.common.Colors.Subheading) str += widget.displayStats(repo)
str += widget.displayMyReviewRequests(repo, username) }
str += fmt.Sprintf("\n [%s]My Pull Requests[white]\n", widget.settings.common.Colors.Subheading) if widget.settings.showOpenReviewRequests {
str += widget.displayMyPullRequests(repo, username) str += fmt.Sprintf("\n [%s]Open Review Requests[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyReviewRequests(repo, username)
}
if widget.settings.showMyPullRequests {
str += fmt.Sprintf("\n [%s]My Pull Requests[white]\n", widget.settings.common.Colors.Subheading)
str += widget.displayMyPullRequests(repo, username)
}
for _, customQuery := range widget.settings.customQueries { for _, customQuery := range widget.settings.customQueries {
str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.common.Colors.Subheading, customQuery.title) str += fmt.Sprintf("\n [%s]%s[white]\n", widget.settings.common.Colors.Subheading, customQuery.title)
str += widget.displayCustomQuery(repo, customQuery.filter, customQuery.perPage) str += widget.displayCustomQuery(repo, customQuery.filter, customQuery.perPage)

View File

@ -16,13 +16,16 @@ const (
type Settings struct { type Settings struct {
common *cfg.Common common *cfg.Common
apiKey string `help:"Your GitHub API token."` apiKey string `help:"Your GitHub API token."`
baseURL string `help:"Your GitHub Enterprise API URL." optional:"true"` baseURL string `help:"Your GitHub Enterprise API URL." optional:"true"`
customQueries []customQuery `help:"Custom queries allow you to filter pull requests and issues however you like. Give the query a title and a filter. Filters can be copied directly from GitHubs UI." optional:"true"` customQueries []customQuery `help:"Custom queries allow you to filter pull requests and issues however you like. Give the query a title and a filter. Filters can be copied directly from GitHubs UI." optional:"true"`
enableStatus bool `help:"Display pull request mergeability status (dirty, clean, unstable, blocked)." optional:"true"` enableStatus bool `help:"Display pull request mergeability status (dirty, clean, unstable, blocked)." optional:"true"`
repositories []string `help:"A list of github repositories." values:"Example: wtfutil/wtf"` repositories []string `help:"A list of github repositories." values:"Example: wtfutil/wtf"`
uploadURL string `help:"Your GitHub Enterprise upload URL (often the same as API URL)." optional:"true"` showMyPullRequests bool `help:"Show my pull requests section" optional:"true"`
username string `help:"Your GitHub username. Used to figure out which review requests youve been added to."` showOpenReviewRequests bool `help:"Show open review requests section" optional:"true"`
showStats bool `help:"Show repository stats section" optional:"true"`
uploadURL string `help:"Your GitHub Enterprise upload URL (often the same as API URL)." optional:"true"`
username string `help:"Your GitHub username. Used to figure out which review requests youve been added to."`
} }
type customQuery struct { type customQuery struct {
@ -36,11 +39,14 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
settings := Settings{ settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_GITHUB_TOKEN"))), apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_GITHUB_TOKEN"))),
baseURL: ymlConfig.UString("baseURL", os.Getenv("WTF_GITHUB_BASE_URL")), baseURL: ymlConfig.UString("baseURL", os.Getenv("WTF_GITHUB_BASE_URL")),
enableStatus: ymlConfig.UBool("enableStatus", false), enableStatus: ymlConfig.UBool("enableStatus", false),
uploadURL: ymlConfig.UString("uploadURL", os.Getenv("WTF_GITHUB_UPLOAD_URL")), showMyPullRequests: ymlConfig.UBool("showMyPullRequests", true),
username: ymlConfig.UString("username"), showOpenReviewRequests: ymlConfig.UBool("showOpenReviewRequests", true),
showStats: ymlConfig.UBool("showStats", true),
uploadURL: ymlConfig.UString("uploadURL", os.Getenv("WTF_GITHUB_UPLOAD_URL")),
username: ymlConfig.UString("username"),
} }
settings.repositories = cfg.ParseAsMapOrList(ymlConfig, "repositories") settings.repositories = cfg.ParseAsMapOrList(ymlConfig, "repositories")
settings.customQueries = parseCustomQueries(ymlConfig) settings.customQueries = parseCustomQueries(ymlConfig)