added in a help dialogue and error message
This commit is contained in:
parent
daf27af34a
commit
d8c20faa65
1 changed files with 11 additions and 9 deletions
|
|
@ -26,19 +26,21 @@ func NewCmdBrowse(f *cmdutil.Factory) *cobra.Command {
|
|||
func openInBrowser(cmd *cobra.Command, f *cmdutil.Factory) {
|
||||
// args := cmd.Args
|
||||
baseRepo, err := f.BaseRepo()
|
||||
w := f.IOStreams.ErrOut
|
||||
cs := f.IOStreams.ColorScheme()
|
||||
help := "Use 'gh browse --help' for more information about browse\n"
|
||||
if err != nil {
|
||||
fmt.Println("error")
|
||||
fmt.Fprintf(w, "%s Navigate to a repository to open in browser\n%s",
|
||||
cs.Red("x"),
|
||||
help)
|
||||
return
|
||||
}
|
||||
|
||||
// ATTN: add into the empty string where you want to go within the repo
|
||||
repoUrl := ghrepo.GenerateRepoURL(baseRepo, "")
|
||||
f.Browser.Browse(repoUrl)
|
||||
fmt.Fprintf(w, "%s Now opening %s in browser . . .\n%s",
|
||||
cs.Green("✓"),
|
||||
cs.Bold(ghrepo.FullName(baseRepo)),
|
||||
help)
|
||||
}
|
||||
|
||||
// Questions for tomorrow:
|
||||
// if logged in / repo
|
||||
// go to repo
|
||||
// else if logged in / !repo
|
||||
// go to profile
|
||||
// else
|
||||
// ? throw error / go to github home page
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue