Skip to content

Commit

Permalink
Merge pull request #2045 from Adirio/completion-option
Browse files Browse the repository at this point in the history
⚠️ Explicitly define WithCompletion as an Option
  • Loading branch information
k8s-ci-robot committed Feb 26, 2021
2 parents d07dfcc + 4bf571c commit cfbf62d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {
),
cli.WithDefaultPlugins(cfgv2.Version, &pluginv2.Plugin{}),
cli.WithDefaultPlugins(cfgv3.Version, &pluginv3.Plugin{}),
cli.WithCompletion,
cli.WithCompletion(),
)
if err != nil {
log.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ var _ = Describe("CLI", func() {

When("enabling completion", func() {
It("should create a valid CLI", func() {
c, err = New(WithCompletion)
c, err = New(WithCompletion())
Expect(err).NotTo(HaveOccurred())
Expect(hasSubCommand(c, "completion")).To(BeTrue())
})
Expand Down
8 changes: 5 additions & 3 deletions pkg/cli/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ func WithExtraCommands(cmds ...*cobra.Command) Option {
}

// WithCompletion is an Option that adds the completion subcommand.
func WithCompletion(c *cli) error {
c.completionCommand = true
return nil
func WithCompletion() Option {
return func(c *cli) error {
c.completionCommand = true
return nil
}
}
2 changes: 1 addition & 1 deletion pkg/cli/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ var _ = Describe("CLI options", func() {
})

It("should add the completion command if requested", func() {
c, err = newCLI(WithCompletion)
c, err = newCLI(WithCompletion())
Expect(err).NotTo(HaveOccurred())
Expect(c).NotTo(BeNil())
Expect(c.completionCommand).To(BeTrue())
Expand Down

0 comments on commit cfbf62d

Please sign in to comment.