use cobra's arg-count validation & call Complete() before Validate()

Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
Steve Kriss
2018-04-03 09:45:29 -07:00
parent a2f5e14a32
commit c60e47dedd
13 changed files with 18 additions and 67 deletions
+1 -4
View File
@@ -50,11 +50,8 @@ func NewAddCommand(f client.Factory) *cobra.Command {
c := &cobra.Command{
Use: "add IMAGE",
Short: "Add a plugin",
Args: cobra.ExactArgs(1),
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
cmd.CheckError(errors.New("you must specify only one argument, the plugin container image"))
}
kubeClient, err := f.KubeClient()
if err != nil {
cmd.CheckError(err)
+1 -4
View File
@@ -35,11 +35,8 @@ func NewRemoveCommand(f client.Factory) *cobra.Command {
c := &cobra.Command{
Use: "remove [NAME | IMAGE]",
Short: "Remove a plugin",
Args: cobra.ExactArgs(1),
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
cmd.CheckError(errors.New("you must specify only one argument, the plugin container's name or image"))
}
kubeClient, err := f.KubeClient()
if err != nil {
cmd.CheckError(err)