mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Add shortcuts for GitHub Pull Requests and Issues (#777)
This commit is contained in:
		
							parent
							
								
									9f6a72d674
								
							
						
					
					
						commit
						4ec9d33a6f
					
				| @ -10,6 +10,12 @@ import ( | ||||
| 	"golang.org/x/oauth2" | ||||
| ) | ||||
| 
 | ||||
| const ( | ||||
| 	pullRequestsPath = "/pulls" | ||||
| 	issuesPath = "/issues" | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| // GithubRepo defines a new GithubRepo structure | ||||
| type GithubRepo struct { | ||||
| 	apiKey    string | ||||
| @ -42,6 +48,16 @@ func (repo *GithubRepo) Open() { | ||||
| 	utils.OpenFile(*repo.RemoteRepo.HTMLURL) | ||||
| } | ||||
| 
 | ||||
| // Open will open the GitHub Pull Requests URL using the utils helper | ||||
| func (repo *GithubRepo) OpenPulls() { | ||||
| 	utils.OpenFile(*repo.RemoteRepo.HTMLURL + pullRequestsPath) | ||||
| } | ||||
| 
 | ||||
| // Open will open the GitHub Issues URL using the utils helper | ||||
| func (repo *GithubRepo) OpenIssues() { | ||||
| 	utils.OpenFile(*repo.RemoteRepo.HTMLURL + issuesPath) | ||||
| } | ||||
| 
 | ||||
| // Refresh reloads the github data via the Github API | ||||
| func (repo *GithubRepo) Refresh() { | ||||
| 	prs, err := repo.loadPullRequests() | ||||
|  | ||||
| @ -12,6 +12,8 @@ func (widget *Widget) initializeKeyboardControls() { | ||||
| 	widget.SetKeyboardChar("l", widget.NextSource, "Select next source") | ||||
| 	widget.SetKeyboardChar("h", widget.PrevSource, "Select previous source") | ||||
| 	widget.SetKeyboardChar("o", widget.openRepo, "Open item in browser") | ||||
| 	widget.SetKeyboardChar("p", widget.openPulls, "Open pull requests in browser") | ||||
| 	widget.SetKeyboardChar("i", widget.openIssues, "Open issues in browser") | ||||
| 
 | ||||
| 	widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item") | ||||
| 	widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item") | ||||
|  | ||||
| @ -157,3 +157,19 @@ func (widget *Widget) openRepo() { | ||||
| 		repo.Open() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (widget *Widget) openPulls() { | ||||
| 	repo := widget.currentGithubRepo() | ||||
| 
 | ||||
| 	if repo != nil { | ||||
| 		repo.OpenPulls() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (widget *Widget) openIssues() { | ||||
| 	repo := widget.currentGithubRepo() | ||||
| 
 | ||||
| 	if repo != nil { | ||||
| 		repo.OpenIssues() | ||||
| 	} | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user