11package browse
22
33import (
4- "github.com/MakeNowJust/heredoc"
4+ "fmt"
5+ "os"
6+
57 "github.com/cli/cli/pkg/cmdutil"
8+ "github.com/cli/cli/pkg/iostreams"
69 "github.com/spf13/cobra"
710)
811
912func NewCmdBrowse (f * cmdutil.Factory ) * cobra.Command {
13+
1014 cmd := & cobra.Command {
11- Use : "browse <command>" ,
12- Short : "" ,
13- Long : `Open GitHub in the browser` ,
14- Example : heredoc .Doc (`
15- $ gh browse issue "217"
16- $ gh browse file "src/main.java"
17- $ gh browse branch "master"
18- ` ),
19- Annotations : map [string ]string {
20- "IsCore" : "true" ,
21- "help:arguments" : heredoc .Doc (`
22- Branch names, pr numbers, issue numbers, and file paths
23- can be supplied as arguments in the following formats:
24- - by number, e.g. “123”; or
25- - by description, e.g. “index.js”
26-
27- ` ),
28- },
15+ Long : "Hello world" , // displays when you are on the help page of this command
16+ Short : "Open GitHub in the browser" , // displays in the gh root help
17+ Use : "browse" , // necessary!!! This is the cmd that gets passed on the prompt
18+ Run : func (cmd * cobra.Command , args []string ) { // run gets rid of the usage
19+ openInBrowser ()
20+ },
2921 }
3022
31- cmdutil .EnableRepoOverride (cmd , f )
32-
23+ cmdutil .EnableRepoOverride (cmd , f )
3324
3425 return cmd
3526}
27+
28+ func openInBrowser () {
29+ fmt .Println ("" );
30+ IO ,_ ,_ ,_ := iostreams .Test () // why is this called test? is it to be used for the final product?
31+ browser := cmdutil .NewBrowser (os .Getenv ("BROWSER" ), IO .Out , IO .ErrOut )
32+ browser .Browse ("www.github.com" )
33+
34+ }
0 commit comments