Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Explicitly define WithCompletion as an Option #2045

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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