diff --git a/cli/providers/providers.go b/cli/providers/providers.go index d3f3426455..070eeb630e 100644 --- a/cli/providers/providers.go +++ b/cli/providers/providers.go @@ -149,6 +149,21 @@ func attachConnectorCmd(provider *plugin.Provider, connector *plugin.Connector, PreRun: cmd.Command.PreRun, } + if connector.MinArgs == connector.MaxArgs { + if connector.MinArgs == 0 { + res.Args = cobra.NoArgs + } else { + res.Args = cobra.ExactArgs(int(connector.MinArgs)) + } + } else { + if connector.MaxArgs > 0 && connector.MinArgs == 0 { + res.Args = cobra.MaximumNArgs(int(connector.MaxArgs)) + } else if connector.MaxArgs == 0 && connector.MinArgs > 0 { + res.Args = cobra.MinimumNArgs(int(connector.MinArgs)) + } else { + res.Args = cobra.RangeArgs(int(connector.MinArgs), int(connector.MaxArgs)) + } + } cmd.Command.Flags().VisitAll(func(flag *pflag.Flag) { res.Flags().AddFlag(flag) })