-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
32 lines (27 loc) · 708 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"fmt"
"github.com/cli/go-gh/v2/pkg/browser"
"github.com/cli/go-gh/v2/pkg/repository"
"log"
"os"
)
func main() {
if len(os.Args) != 2 {
log.Fatal("error: need one argument.")
}
// TODO: should validate arg to comply with https://github.com/mislav/hub/blob/master/commands/compare.go
arg := os.Args[1]
repo, err := repository.Current()
if err != nil {
log.Fatal(err)
}
url := fmt.Sprintf("https://%s/%s/%s/compare/%s", repo.Host, repo.Owner, repo.Name, arg)
b := browser.New("", os.Stdout, os.Stderr)
err = b.Browse(url)
if err != nil {
log.Fatal(err)
}
}
// For more examples of using go-gh, see:
// https://github.com/cli/go-gh/blob/trunk/example_gh_test.go