added in a help dialogue and error message

This commit is contained in:
Ben 2021-05-19 22:14:58 -07:00
parent daf27af34a
commit d8c20faa65

View file

@ -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