Skip to content

Fix help with value flags#1006

Merged
chaptersix merged 5 commits intotemporalio:mainfrom
kevinawoo:codex/fix-help-value-flags
Apr 30, 2026
Merged

Fix help with value flags#1006
chaptersix merged 5 commits intotemporalio:mainfrom
kevinawoo:codex/fix-help-value-flags

Conversation

@kevinawoo
Copy link
Copy Markdown
Member

@kevinawoo kevinawoo commented Apr 29, 2026

Summary

  • avoid routing built-in help invocations through extension probing when known value flags are present
  • initialize Cobra's default help flag before extension preflight parses command flags
  • add regression coverage for --help combined with --address and --namespace

Root Cause

Extension preflight checked raw remaining args with a string-prefix heuristic. Values for known flags, such as 123 in --address 123, looked like positional extension args, so the preflight parsed --help before Cobra had registered the default help flag and surfaced pflag: help requested as a real error.

Fixes #1003.

Validation

  • go run ./cmd/temporal workflow list --address 123 --help
  • go test ./internal/temporalcli -run 'TestHelp|TestExtension' -count=1
  • go test ./internal/temporalcli -count=1

@kevinawoo kevinawoo changed the title [codex] Fix help with value flags Fix help with value flags Apr 29, 2026
@kevinawoo kevinawoo marked this pull request as ready for review April 29, 2026 00:58
@kevinawoo kevinawoo requested a review from a team as a code owner April 29, 2026 00:58
Comment on lines +38 to +42
foundCmd.InitDefaultHelpFlag()
cliParseArgs, cliPassArgs, extArgs := groupArgs(foundCmd, remainingArgs)
if findErr == nil && !slices.ContainsFunc(extArgs, isPosArg) {
return nil, false
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix comment alignment

add back the comments removed on 34 (in the correct location)

add a comment on why InitDefaultHelpFlag() is being called

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

kevinawoo and others added 4 commits April 29, 2026 09:53
When --help/-h appears after positional args in the extension dispatch
path, route it to extArgs so it gets forwarded to the extension binary.
This prevents the help flag from being intercepted by the parent command.
Verify that built-in help is shown (not extension invoked) when --help
is combined with value flags like --address and --namespace, even when
a matching extension exists on PATH.
@chaptersix chaptersix merged commit 1a064e5 into temporalio:main Apr 30, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--help flag prints 'pflag: help requested' when used with other flags

3 participants