Get rid of argsLenAtDash in create job

parent 59fc1200
...@@ -85,8 +85,7 @@ func NewCmdCreateJob(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) * ...@@ -85,8 +85,7 @@ func NewCmdCreateJob(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *
Long: jobLong, Long: jobLong,
Example: jobExample, Example: jobExample,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
argsLenAtDash := cmd.ArgsLenAtDash() cmdutil.CheckErr(o.Complete(f, cmd, args))
cmdutil.CheckErr(o.Complete(f, cmd, args, argsLenAtDash))
cmdutil.CheckErr(o.Validate()) cmdutil.CheckErr(o.Validate())
cmdutil.CheckErr(o.Run()) cmdutil.CheckErr(o.Run())
}, },
...@@ -103,11 +102,12 @@ func NewCmdCreateJob(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) * ...@@ -103,11 +102,12 @@ func NewCmdCreateJob(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *
return cmd return cmd
} }
func (o *CreateJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string, argsLenAtDash int) error { func (o *CreateJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []string) error {
if len(args) == 0 || argsLenAtDash == 0 { name, err := NameFromCommandArgs(cmd, args)
return cmdutil.UsageErrorf(cmd, "NAME is required") if err != nil {
return err
} }
o.Name = args[0] o.Name = name
if len(args) > 1 { if len(args) > 1 {
o.Command = args[1:] o.Command = args[1:]
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment