From d656a9077b35fea1e6aeaa0347c2214a9a29001d Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 15 May 2021 21:40:43 -0700 Subject: [PATCH] cleaned up the code base, opening the web browser is now matching the style of th e repo. We also made a dialogue in our helpful-resources.txt about what we will be doing next. Big things to comegit add . --- pkg/cmd/browse/browse.go | 35 +++++++++++++++++----------- pkg/cmd/browse/helpful-resources.txt | 12 ++++++++++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/pkg/cmd/browse/browse.go b/pkg/cmd/browse/browse.go index b2b016e2a..2880a75aa 100644 --- a/pkg/cmd/browse/browse.go +++ b/pkg/cmd/browse/browse.go @@ -1,11 +1,7 @@ package browse import ( - "fmt" - "os" - "github.com/cli/cli/pkg/cmdutil" - "github.com/cli/cli/pkg/iostreams" "github.com/spf13/cobra" ) @@ -15,20 +11,31 @@ func NewCmdBrowse(f *cmdutil.Factory) *cobra.Command { Long: "Hello world", // displays when you are on the help page of this command Short: "Open GitHub in the browser", // displays in the gh root help Use: "browse", // necessary!!! This is the cmd that gets passed on the prompt - Run: func(cmd *cobra.Command, args []string) { // run gets rid of the usage - openInBrowser() + Run: func(cmd *cobra.Command, args []string) { // run gets rid of the usage / runs function + openInBrowser(cmd, f) }, } - cmdutil.EnableRepoOverride(cmd, f) + cmdutil.EnableRepoOverride(cmd, f) // Q: what does this do??? return cmd } -func openInBrowser() { - fmt.Println(""); - IO,_,_,_ := iostreams.Test() // why is this called test? is it to be used for the final product? - browser := cmdutil.NewBrowser(os.Getenv("BROWSER"), IO.Out, IO.ErrOut) - browser.Browse("www.github.com") - -} \ No newline at end of file +func openInBrowser(cmd *cobra.Command, f *cmdutil.Factory) { + const root = "www.github.com" + f.Browser.Browse(root) +} + + +/* +Moving forward, since we can open in the browser we need to discuss logic of arguments + +This includes: +1. Open the repo in browser with just "gh browse" +2. Make the help instruction display while opening using IOStreams +3. Find out how "cmd" stores args within, to be parsed +4. Make a table of all the possible inputs that are valid +5. Possibly work on error handling +6. Clarify table with client before moving forward with args + +*/ \ No newline at end of file diff --git a/pkg/cmd/browse/helpful-resources.txt b/pkg/cmd/browse/helpful-resources.txt index 7a710cd94..3705651ba 100644 --- a/pkg/cmd/browse/helpful-resources.txt +++ b/pkg/cmd/browse/helpful-resources.txt @@ -8,3 +8,15 @@ https://github.com/cli/cli/blob/trunk/docs/project-layout.md Our working fork https://github.com/bchadwic/cli/tree/trunk +https://umarcor.github.io/cobra/#example + +5/15/21 +Moving forward, since we can open in the browser we need to discuss logic of arguments + +This includes: +1. Open the repo in browser with just "gh browse" +2. Make the help instruction display while opening using IOStreams +3. Find out how "cmd" stores args within, to be parsed +4. Make a table of all the possible inputs that are valid +5. Possibly work on error handling +6. Clarify table with client before moving forward with args \ No newline at end of file