mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 01:06:45 +08:00
implement browse feature
This commit is contained in:
1 parent
ed41c19bbf
commit
0c405b495f
5 files changed
+48
-8
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package browse
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/daveberrys/guh/src/cmd"
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/pkg/browser"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd.RootCmd.AddCommand(createCmd)
|
||||
}
|
||||
|
||||
var createCmd = &cobra.Command{
|
||||
Use: "browse",
|
||||
Short: "Opens a browser to the repository.",
|
||||
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)
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user