Skip to content

fix(cli): repeatable array flags example rendering - #26

Merged
2ynn merged 4 commits into
mainfrom
fix/cli/repeatable-flags-example-rendering
Sep 22, 2026
Merged

2ynn merged 4 commits into
mainfrom
fix/cli/repeatable-flags-example-rendering

Conversation

@2ynn

@2ynn 2ynn commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Fix generated CLI examples for repeatable string and enum array flags by emitting one flag occurrence per element. Preserve JSON encoding for other arrays, shell-quote values, and add coverage verifying the rendered command produces the correct request payload.

Fix generated CLI examples for repeatable string and enum array flags by rendering each element as a separate flag occurrence.
Before: --labels '["release-1","release-2"]'
After: --labels release-1 --labels release-2

Non-repeatable arrays continue to use a single JSON-encoded value, such as --weights '[1.5,2]'. The change also shell-quotes individual example values and adds generated CLI coverage for the rendered command and request payload.


Summary by cubic

Fixes generated CLI examples for repeatable string and enum array flags by rendering each element as a separate flag occurrence instead of a single JSON-encoded token.

  • Before: --labels '["release-1","release-2"]'; after: --labels release-1 --labels release-2.
  • Field-level, request body, and query parameter examples now all route through one helper, including intent-command examples.
  • Empty arrays on repeatable flags fall through to the placeholder; enum-item repeatable flags without an example render the first enum value, since array defaults aren't modeled for the CLI target.
  • Non-repeatable arrays (e.g., number arrays) still render as one JSON-encoded value.
  • Example values are shell-quoted where needed, leaving <value> placeholders bare, and generated tests execute the rendered example to verify the request payload.

Written for commit 03919c6. Summary will update on new commits.

Review in cubic

@2ynn
2ynn requested a review from a team as a code owner September 22, 2026 12:50
@2ynn
2ynn requested a review from AshGodfrey September 22, 2026 12:50

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread templates/templates/cli/includes/descriptions.ts Outdated
Comment thread templates/templates/cli/includes/descriptions.ts
Comment thread templates/templates/cli/tests/primary/requestbodies_additional_test.go.stmpl Outdated
Route field-level, body and parameter examples through one helper so a
non-repeatable array example is JSON-encoded on every path, an empty array
on a repeatable flag falls through to the placeholder, and intent-command
examples render one flag occurrence per element too.

Execute the rendered example in the generated tests instead of retyping
its flags, and cover a repeatable query parameter. Regenerate the review
CLI for the quoted example values and note the quoting in the changeset.
An empty array example on a repeatable parameter rendered as a literal
"[]" token in synthesized intent examples. Gate the parameter-level
example with the same presence check the operation examples use so it
falls through to the placeholder instead.
The repeatable-flag fragment relied on an array default to fill an empty
example, but array defaults are not modeled for the CLI target, so the
field rendered a placeholder and compact help blanked the whole example.

Resolve the example against the per-value type: a repeatable flag over
enum items takes the first enum value, matching scalar enum fields. The
fragment now covers that path instead of the unsupported array default.
@2ynn
2ynn force-pushed the fix/cli/repeatable-flags-example-rendering branch from 9ff688f to 03919c6 Compare September 22, 2026 14:32
@2ynn
2ynn added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit fd85a10 Sep 22, 2026
168 checks passed
@2ynn
2ynn deleted the fix/cli/repeatable-flags-example-rendering branch September 22, 2026 16:30
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants