Repository navigation
Conversation
pflag takes the first backticked word in a flag's usage as the value name, so Cisco's Markdown code spans showed as `--search validate=true` and `--input-name allowedValues`. Backticks are now dropped from usage when the flag is registered; pkg/webexops keeps Cisco's descriptions as they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JAtGHcFAKjQdB6dwDKd8mW
Building a strings.Replacer per parameter added about 35 MB of allocations to every CLI start, since every API command's flags are registered then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JAtGHcFAKjQdB6dwDKd8mW
edumansky
left a comment
There was a problem hiding this comment.
Codex review (gpt-6.2-astra, reasoning effort: high)
The flag placeholders are corrected, and the focused regression test and golden tests pass. The implementation nevertheless adds roughly 35 MB of avoidable allocations to every CLI invocation.
| // the first `word` in a usage as the flag's value name, and Cisco's descriptions | ||
| // use backticks only to mark code, so they are dropped. | ||
| func flagUsage(description string) string { | ||
| return strings.NewReplacer("\n", " ", "`", "").Replace(description) |
There was a problem hiding this comment.
[P2] Reuse the flag-help replacer across parameters
flagUsage builds the same replacement table for every parameter. All six command areas use this builder at startup, even for webex --version. With GODEBUG=inittrace=1, those areas allocated about 43 MB during initialization versus 8 MB on the base branch. Construct the strings.Replacer once at package scope and reuse it to preserve the corrected help without the extra startup allocations.
There was a problem hiding this comment.
Valid, fixed in 9640f7f. The replacer is now built once at package scope (usageReplacer). Measured with GODEBUG=inittrace=1 webex --version: 42.8 MB in cmd/ inits before, 8.6 MB after (8.3 MB on main). Regression test: TestFlagUsageAllocatesOnlyItsResult checks that flagUsage makes at most one allocation.
Codex review: outcomeCodex's one finding was valid and is fixed in 9640f7f:
Checks at 9640f7f:
|
Why
pflag treats the first
`word`in a flag's usage as the name of the value the flag takes. It shows that word after the flag and removes those backticks. Cisco's parameter descriptions use backticks for code, so 615 generated flags showed a word from their description where the value type should be. Later backticks stayed in the text. Fromwebex cc activities get-input-choices --help:--searchtakes a string, but its help reads as if it takesvalidate=true.What changes
internal/apicmdremoves backticks from a parameter's description when it registers the flag. Every generated flag now shows its type:pkg/webexopsstill has Cisco's descriptions unchanged, so the skill references and SDK users still get the Markdown.Golden files
In
testdata/golden/commands.json, the only changed lines are 615 flagusagelines, which lost their backticks. The recorded requests are unchanged. The golden file doesn't record the value name, soTestAFlagWithCodeInItsUsageShowsItsTypechecks it.Checks
go vet ./...andgo test -p 1 -timeout 300s ./...pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01JAtGHcFAKjQdB6dwDKd8mW
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.