Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions pkg/cmd/kafka/consumergroup/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
strimziadminclient "github.com/redhat-developer/app-services-cli/pkg/api/strimzi-admin/client"
"github.com/redhat-developer/app-services-cli/pkg/cmd/factory"
"github.com/redhat-developer/app-services-cli/pkg/cmd/flag"
flagutil "github.com/redhat-developer/app-services-cli/pkg/cmdutil/flags"
"github.com/redhat-developer/app-services-cli/pkg/color"
"github.com/redhat-developer/app-services-cli/pkg/connection"
"github.com/redhat-developer/app-services-cli/pkg/dump"
Expand Down Expand Up @@ -93,6 +94,10 @@ func NewDescribeConsumerGroupCommand(f *factory.Factory) *cobra.Command {
return cmdutil.FilterValidConsumerGroupIDs(f, toComplete)
})

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work but this is being duplicated in every file and they are the same. Could you extract this into the flagutil package?

return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/kafka/consumergroup/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func NewListConsumerGroupCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().StringVarP(&opts.output, "output", "o", "", opts.localizer.MustLocalize("kafka.consumerGroup.list.flag.output.description"))
cmd.Flags().StringVar(&opts.topic, "topic", "", opts.localizer.MustLocalize("kafka.consumerGroup.list.flag.topic.description"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/kafka/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func NewCreateCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "json", opts.localizer.MustLocalize("kafka.common.flag.output.description"))
cmd.Flags().BoolVar(&opts.autoUse, "use", true, opts.localizer.MustLocalize("kafka.create.flag.autoUse.description"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/kafka/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func NewDescribeCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "json", opts.localizer.MustLocalize("kafka.common.flag.output.description"))
cmd.Flags().StringVar(&opts.id, "id", "", opts.localizer.MustLocalize("kafka.describe.flag.id"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/kafka/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func NewListCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().IntVarP(&opts.limit, "limit", "", 100, opts.localizer.MustLocalize("kafka.list.flag.limit"))
cmd.Flags().StringVarP(&opts.search, "search", "", "", opts.localizer.MustLocalize("kafka.list.flag.search"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/cmd/kafka/topic/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/redhat-developer/app-services-cli/pkg/cmd/flag"

strimziadminclient "github.com/redhat-developer/app-services-cli/pkg/api/strimzi-admin/client"
flagutil "github.com/redhat-developer/app-services-cli/pkg/cmdutil/flags"
"github.com/redhat-developer/app-services-cli/pkg/dump"
"github.com/redhat-developer/app-services-cli/pkg/iostreams"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -119,6 +120,10 @@ func NewCreateTopicCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().IntVar(&opts.retentionMs, "retention-ms", defaultRetentionPeriodMS, opts.localizer.MustLocalize("kafka.topic.common.input.retentionMs.description"))
cmd.Flags().IntVar(&opts.retentionBytes, "retention-bytes", defaultRetentionSize, opts.localizer.MustLocalize("kafka.topic.common.input.retentionBytes.description"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/kafka/topic/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/redhat-developer/app-services-cli/pkg/cmd/factory"
"github.com/redhat-developer/app-services-cli/pkg/logging"

flagutil "github.com/redhat-developer/app-services-cli/pkg/cmdutil/flags"

"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -86,6 +88,10 @@ func NewDescribeTopicCommand(f *factory.Factory) *cobra.Command {

cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "json", opts.localizer.MustLocalize("kafka.topic.common.flag.output.description"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/kafka/topic/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (

strimziadminclient "github.com/redhat-developer/app-services-cli/pkg/api/strimzi-admin/client"

flagutil "github.com/redhat-developer/app-services-cli/pkg/cmdutil/flags"

"gopkg.in/yaml.v2"

"github.com/redhat-developer/app-services-cli/internal/config"
Expand Down Expand Up @@ -81,6 +83,10 @@ func NewListTopicCommand(f *factory.Factory) *cobra.Command {

cmd.Flags().StringVarP(&opts.output, "output", "o", "", opts.localizer.MustLocalize("kafka.topic.list.flag.output.description"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/cmd/kafka/topic/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/redhat-developer/app-services-cli/pkg/connection"
"github.com/redhat-developer/app-services-cli/pkg/localize"

flagutil "github.com/redhat-developer/app-services-cli/pkg/cmdutil/flags"
topicutil "github.com/redhat-developer/app-services-cli/pkg/kafka/topic"

"github.com/redhat-developer/app-services-cli/pkg/cmd/flag"
Expand Down Expand Up @@ -156,6 +157,10 @@ func NewUpdateTopicCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().StringVar(&opts.retentionMsStr, "retention-ms", "", opts.localizer.MustLocalize("kafka.topic.common.input.retentionMs.description"))
cmd.Flags().StringVar(&opts.retentionBytesStr, "retention-bytes", "", opts.localizer.MustLocalize("kafka.topic.common.input.retentionBytes.description"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/serviceaccount/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func NewCreateCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().StringVar(&opts.filename, "file-location", "", opts.localizer.MustLocalize("serviceAccount.common.flag.fileLocation.description"))
cmd.Flags().StringVar(&opts.fileFormat, "file-format", "", opts.localizer.MustLocalize("serviceAccount.common.flag.fileFormat.description"))

_ = cmd.RegisterFlagCompletionFunc("file-format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.CredentialsOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/serviceaccount/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func NewDescribeCommand(f *factory.Factory) *cobra.Command {

_ = cmd.MarkFlagRequired("id")

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/serviceaccount/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func NewListCommand(f *factory.Factory) *cobra.Command {

cmd.Flags().StringVarP(&opts.output, "output", "o", "", opts.localizer.MustLocalize("serviceAccount.list.flag.output.description"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/serviceaccount/resetcredentials/reset_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func NewResetCredentialsCommand(f *factory.Factory) *cobra.Command {
cmd.Flags().StringVar(&opts.fileFormat, "file-format", "", opts.localizer.MustLocalize("serviceAccount.common.flag.fileFormat.description"))
cmd.Flags().BoolVarP(&opts.force, "yes", "y", false, opts.localizer.MustLocalize("serviceAccount.resetCredentials.flag.yes.description"))

_ = cmd.RegisterFlagCompletionFunc("file-format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also duplicated. I would say any one with more than one occurrence can be extracted to flagutil.

return flagutil.CredentialsOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func NewStatusCommand(f *factory.Factory) *cobra.Command {

cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "", opts.localizer.MustLocalize("status.flag.output.description"))

_ = cmd.RegisterFlagCompletionFunc("output", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return flagutil.ValidOutputFormats, cobra.ShellCompDirectiveNoSpace
})

return cmd
}

Expand Down