From 52045e47cdde91b297223140e47b67b68bb89213 Mon Sep 17 00:00:00 2001 From: Clay McGinnis Date: Tue, 8 Sep 2026 10:51:04 -0700 Subject: [PATCH] fix(jobs): explain missing positional arguments (WBC-266) --- internal/commands/jobs.go | 30 ++++++++++++++--------- internal/commands/jobs_test.go | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 12 deletions(-) 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