diff --git a/src/cmd/browse/issues.go b/src/cmd/browse/issues.go new file mode 100644 index 0000000..209a7ca --- /dev/null +++ b/src/cmd/browse/issues.go @@ -0,0 +1,20 @@ +package browse + +import ( + "strings" + + "github.com/daveberrys/guh/src/utils" + "github.com/spf13/cobra" + "github.com/pkg/browser" +) + +var issuesCmd = &cobra.Command{ + Use: "issues", + Short: "Opens a browser to the issues page.", + RunE: func(cmd *cobra.Command, args []string) error { + url, err := utils.RunGit(true, "remote", "get-url", "origin") + if err != nil { return err } + url = strings.TrimSuffix(url, ".git") + return browser.OpenURL(url + "/issues") + }, +} diff --git a/src/cmd/browse/pr.go b/src/cmd/browse/pr.go new file mode 100644 index 0000000..3df1ec8 --- /dev/null +++ b/src/cmd/browse/pr.go @@ -0,0 +1,20 @@ +package browse + +import ( + "strings" + + "github.com/daveberrys/guh/src/utils" + "github.com/spf13/cobra" + "github.com/pkg/browser" +) + +var prCmd = &cobra.Command{ + Use: "pr", + Short: "Opens a browser to the PRs page.", + RunE: func(cmd *cobra.Command, args []string) error { + url, err := utils.RunGit(true, "remote", "get-url", "origin") + if err != nil { return err } + url = strings.TrimSuffix(url, ".git") + return browser.OpenURL(url + "/pulls") + }, +} diff --git a/src/cmd/browse/root.go b/src/cmd/browse/root.go index 034cc26..57e3433 100644 --- a/src/cmd/browse/root.go +++ b/src/cmd/browse/root.go @@ -11,6 +11,8 @@ import ( func init() { cmd.RootCmd.AddCommand(createCmd) + createCmd.AddCommand(prCmd) + createCmd.AddCommand(issuesCmd) } var createCmd = &cobra.Command{