From 74d6eb96be080ae01a7e862129c88739cb9aa5e4 Mon Sep 17 00:00:00 2001 From: Sam Coe Date: Wed, 30 Sep 2020 12:52:45 +0200 Subject: [PATCH] Address PR comments --- pkg/cmd/completion/completion.go | 4 ++-- pkg/cmd/completion/completion_test.go | 6 +----- pkg/cmd/root/root.go | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/cmd/completion/completion.go b/pkg/cmd/completion/completion.go index 7c1ec46f0..3d3699b5d 100644 --- a/pkg/cmd/completion/completion.go +++ b/pkg/cmd/completion/completion.go @@ -6,11 +6,11 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/cli/cli/pkg/cmdutil" + "github.com/cli/cli/pkg/iostreams" "github.com/spf13/cobra" ) -func NewCmdCompletion(f *cmdutil.Factory) *cobra.Command { - io := f.IOStreams +func NewCmdCompletion(io *iostreams.IOStreams) *cobra.Command { var shellType string cmd := &cobra.Command{ diff --git a/pkg/cmd/completion/completion_test.go b/pkg/cmd/completion/completion_test.go index d75c71398..3ce03f9b6 100644 --- a/pkg/cmd/completion/completion_test.go +++ b/pkg/cmd/completion/completion_test.go @@ -4,7 +4,6 @@ import ( "strings" "testing" - "github.com/cli/cli/pkg/cmdutil" "github.com/cli/cli/pkg/iostreams" "github.com/google/shlex" "github.com/spf13/cobra" @@ -46,10 +45,7 @@ func TestNewCmdCompletion(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { io, _, stdout, stderr := iostreams.Test() - f := &cmdutil.Factory{ - IOStreams: io, - } - completeCmd := NewCmdCompletion(f) + completeCmd := NewCmdCompletion(io) rootCmd := &cobra.Command{Use: "gh"} rootCmd.AddCommand(completeCmd) diff --git a/pkg/cmd/root/root.go b/pkg/cmd/root/root.go index 16276fd22..7a82f0cbf 100644 --- a/pkg/cmd/root/root.go +++ b/pkg/cmd/root/root.go @@ -67,7 +67,7 @@ func NewCmdRoot(f *cmdutil.Factory, version, buildDate string) *cobra.Command { cmd.AddCommand(configCmd.NewCmdConfig(f)) cmd.AddCommand(creditsCmd.NewCmdCredits(f, nil)) cmd.AddCommand(gistCmd.NewCmdGist(f)) - cmd.AddCommand(completionCmd.NewCmdCompletion(f)) + cmd.AddCommand(completionCmd.NewCmdCompletion(f.IOStreams)) // the `api` command should not inherit any extra HTTP headers bareHTTPCmdFactory := *f