Skip to content

Commit 444d889

Browse files
committed
make rest client in worktree
1 parent e22c6a6 commit 444d889

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

gh-worktree

0 Bytes
Binary file not shown.

internal/worktree/worktree.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ package worktree
33
import (
44
"fmt"
55

6-
ghapi "github.com/cli/go-gh/pkg/api"
6+
"github.com/cli/go-gh"
77
"github.com/despreston/gh-worktree/internal/worktree/commands/pr"
88
"github.com/spf13/cobra"
99
)
1010

11-
func New(restClient ghapi.RESTClient) *cobra.Command {
11+
func New() (*cobra.Command, error) {
12+
rest, err := gh.RESTClient(nil)
13+
if err != nil {
14+
return nil, err
15+
}
16+
1217
var rootCmd = &cobra.Command{
1318
Use: "worktree",
1419
Short: "Git worktrees, dawg",
@@ -18,6 +23,6 @@ func New(restClient ghapi.RESTClient) *cobra.Command {
1823
},
1924
}
2025

21-
rootCmd.AddCommand(pr.New(restClient))
22-
return rootCmd
26+
rootCmd.AddCommand(pr.New(rest))
27+
return rootCmd, nil
2328
}

main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/cli/go-gh"
87
"github.com/despreston/gh-worktree/internal/worktree"
98
)
109

1110
func main() {
12-
rest, err := gh.RESTClient(nil)
11+
cmd, err := worktree.New()
1312
if err != nil {
1413
fmt.Fprintln(os.Stderr, err)
1514
os.Exit(1)
1615
}
1716

18-
cmd := worktree.New(rest)
1917
if err := cmd.Execute(); err != nil {
2018
fmt.Fprintln(os.Stderr, err)
2119
os.Exit(1)

0 commit comments

Comments
 (0)