Move completion command out of root package
This commit is contained in:
parent
c52fc72291
commit
f00a0f2854
3 changed files with 11 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package root
|
||||
package completion
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
@ -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(io *iostreams.IOStreams) *cobra.Command {
|
||||
func NewCmdCompletion(f *cmdutil.Factory) *cobra.Command {
|
||||
io := f.IOStreams
|
||||
var shellType string
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
package root
|
||||
package completion
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cli/cli/pkg/cmdutil"
|
||||
"github.com/cli/cli/pkg/iostreams"
|
||||
"github.com/google/shlex"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -45,7 +46,10 @@ func TestNewCmdCompletion(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
io, _, stdout, stderr := iostreams.Test()
|
||||
completeCmd := NewCmdCompletion(io)
|
||||
f := &cmdutil.Factory{
|
||||
IOStreams: io,
|
||||
}
|
||||
completeCmd := NewCmdCompletion(f)
|
||||
rootCmd := &cobra.Command{Use: "gh"}
|
||||
rootCmd.AddCommand(completeCmd)
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ import (
|
|||
aliasCmd "github.com/cli/cli/pkg/cmd/alias"
|
||||
apiCmd "github.com/cli/cli/pkg/cmd/api"
|
||||
authCmd "github.com/cli/cli/pkg/cmd/auth"
|
||||
completionCmd "github.com/cli/cli/pkg/cmd/completion"
|
||||
configCmd "github.com/cli/cli/pkg/cmd/config"
|
||||
"github.com/cli/cli/pkg/cmd/factory"
|
||||
gistCmd "github.com/cli/cli/pkg/cmd/gist"
|
||||
|
|
@ -88,7 +89,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(NewCmdCompletion(f.IOStreams))
|
||||
cmd.AddCommand(completionCmd.NewCmdCompletion(f))
|
||||
|
||||
// Help topics
|
||||
cmd.AddCommand(NewHelpTopic("environment"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue