diff --git a/internal/commands/jobs.go b/internal/commands/jobs.go index 158af71..ee9deef 100644 --- a/internal/commands/jobs.go +++ b/internal/commands/jobs.go @@ -158,6 +158,21 @@ func findOperation(runtimeSpec *spec.RuntimeSpec, method, path string) *spec.Ope return nil } +func requiredJobArgument(name, example string) cobra.PositionalArgs { + return func(cmd *cobra.Command, args []string) error { + if len(args) == 1 && strings.TrimSpace(args[0]) != "" { + return nil + } + + message := fmt.Sprintf("missing required argument <%s>", name) + if len(args) > 1 { + message = fmt.Sprintf("expected one <%s> argument, received %d", name, len(args)) + } + return fmt.Errorf("%s\n\nUsage: %s\nExample: %s %s\nRun '%s --help' for options.", + message, cmd.UseLine(), cmd.CommandPath(), example, cmd.CommandPath()) + } +} + func (r *jobsRunner) newCreateCommand() *cobra.Command { var ( name string @@ -178,14 +193,11 @@ func (r *jobsRunner) newCreateCommand() *cobra.Command { cmd := &cobra.Command{ Use: "create