mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 01:06:45 +08:00
browse optional print
This commit is contained in:
1 parent
f380c3c581
commit
100790526b
3 files changed
+27
-6
No files matched your search
@@ -2,6 +2,7 @@ package browse
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -9,12 +10,18 @@ import (
|
||||
)
|
||||
|
||||
var issuesCmd = &cobra.Command{
|
||||
Use: "issues",
|
||||
Short: "Opens a browser to the issues page.",
|
||||
Use: "issues [print]",
|
||||
Short: "Opens a browser to the issues page. If 'print' is true, prints the URL instead.",
|
||||
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")
|
||||
if len(args) > 0 && args[0] == "print" {
|
||||
fmt.Println(url + "/issues")
|
||||
return nil
|
||||
}
|
||||
|
||||
return browser.OpenURL(url + "/issues")
|
||||
},
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package browse
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -9,12 +10,18 @@ import (
|
||||
)
|
||||
|
||||
var prCmd = &cobra.Command{
|
||||
Use: "pr",
|
||||
Short: "Opens a browser to the PRs page.",
|
||||
Use: "pr [print]",
|
||||
Short: "Opens a browser to the PRs page. If 'print' is true, prints the URL instead.",
|
||||
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")
|
||||
if len(args) > 0 && args[0] == "print" {
|
||||
fmt.Println(url + "/pulls")
|
||||
return nil
|
||||
}
|
||||
|
||||
return browser.OpenURL(url + "/pulls")
|
||||
},
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package browse
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
|
||||
"github.com/daveberrys/guh/src/cmd"
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
@@ -16,12 +17,18 @@ func init() {
|
||||
}
|
||||
|
||||
var createCmd = &cobra.Command{
|
||||
Use: "browse",
|
||||
Short: "Opens a browser to the repository.",
|
||||
Use: "browse [print]",
|
||||
Short: "Opens a browser to the repository. If 'print' is true, prints the URL instead.",
|
||||
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")
|
||||
if len(args) > 0 && args[0] == "print" {
|
||||
fmt.Println(url)
|
||||
return nil
|
||||
}
|
||||
|
||||
return browser.OpenURL(url)
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user