X Tutup
Skip to content

Commit f00a0f2

Browse files
committed
Move completion command out of root package
1 parent c52fc72 commit f00a0f2

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package root
1+
package completion
22

33
import (
44
"errors"
55
"fmt"
66

77
"github.com/MakeNowJust/heredoc"
88
"github.com/cli/cli/pkg/cmdutil"
9-
"github.com/cli/cli/pkg/iostreams"
109
"github.com/spf13/cobra"
1110
)
1211

13-
func NewCmdCompletion(io *iostreams.IOStreams) *cobra.Command {
12+
func NewCmdCompletion(f *cmdutil.Factory) *cobra.Command {
13+
io := f.IOStreams
1414
var shellType string
1515

1616
cmd := &cobra.Command{
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
package root
1+
package completion
22

33
import (
44
"strings"
55
"testing"
66

7+
"github.com/cli/cli/pkg/cmdutil"
78
"github.com/cli/cli/pkg/iostreams"
89
"github.com/google/shlex"
910
"github.com/spf13/cobra"
@@ -45,7 +46,10 @@ func TestNewCmdCompletion(t *testing.T) {
4546
for _, tt := range tests {
4647
t.Run(tt.name, func(t *testing.T) {
4748
io, _, stdout, stderr := iostreams.Test()
48-
completeCmd := NewCmdCompletion(io)
49+
f := &cmdutil.Factory{
50+
IOStreams: io,
51+
}
52+
completeCmd := NewCmdCompletion(f)
4953
rootCmd := &cobra.Command{Use: "gh"}
5054
rootCmd.AddCommand(completeCmd)
5155

pkg/cmd/root/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
aliasCmd "github.com/cli/cli/pkg/cmd/alias"
1414
apiCmd "github.com/cli/cli/pkg/cmd/api"
1515
authCmd "github.com/cli/cli/pkg/cmd/auth"
16+
completionCmd "github.com/cli/cli/pkg/cmd/completion"
1617
configCmd "github.com/cli/cli/pkg/cmd/config"
1718
"github.com/cli/cli/pkg/cmd/factory"
1819
gistCmd "github.com/cli/cli/pkg/cmd/gist"
@@ -88,7 +89,7 @@ func NewCmdRoot(f *cmdutil.Factory, version, buildDate string) *cobra.Command {
8889
cmd.AddCommand(configCmd.NewCmdConfig(f))
8990
cmd.AddCommand(creditsCmd.NewCmdCredits(f, nil))
9091
cmd.AddCommand(gistCmd.NewCmdGist(f))
91-
cmd.AddCommand(NewCmdCompletion(f.IOStreams))
92+
cmd.AddCommand(completionCmd.NewCmdCompletion(f))
9293

9394
// Help topics
9495
cmd.AddCommand(NewHelpTopic("environment"))

0 commit comments

Comments
 (0)
X Tutup