Skip to content

feat: allow required variadic flags - #21

Merged
bcdxn merged 2 commits into
bcdxn:mainfrom
bhouston:feature/required-variadic-flags
Sep 29, 2026
Merged

bcdxn merged 2 commits into
bcdxn:mainfrom
bhouston:feature/required-variadic-flags

Conversation

@bhouston

Copy link
Copy Markdown
Contributor

Closes #20

A flag can now be both required: true and variadic: true, meaning it must be supplied at least once and accepts multiple values. This matches Yargs demandOption on array options, Commander mandatory variadic options, and oclif required + multiple. Arguments already allowed this combination.

Changes

  • validate: remove the rule rejecting required on variadic flags.
  • spec.schema.json (and the copies in validate/ and web/src/): document that required and variadic may be combined, and that minItems/maxItems constrain values when the flag is supplied.
  • Tests: replaced the rejection case with a positive validation test, and added a yargs generator test confirming a required variadic flag emits type: "array" with demandOption: true.

No generator changes were needed. Yargs already demands required flags regardless of arity; cobra and urfave-cli do not currently enforce required flags at all, so they are unaffected.

go generate ./... and go test ./... pass.

Closes bcdxn#20

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The Yargs test assertion does not reliably verify the required generated action contract.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Allows flags to be both required and variadic, updating validation, schemas, and Yargs coverage.

Changes:

  • Permit required variadic flags.
  • Update all schema copies.
  • Add validation and Yargs generator tests.
File Summary
web/​src/​spec.schema.json Documents required variadic flags.
validate/​validate.go Removes the conflicting validation rule.
validate/​validate_test.go Adds positive validation coverage.
validate/​spec.schema.json Updates validator schema documentation.
spec.schema.json Updates canonical schema documentation.
gen/​cli_yargs_variadic_test.go Tests required variadic Yargs output; its assertion should verify the exact generated required contract.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread gen/cli_yargs_variadic_test.go Outdated
@bcdxn
bcdxn self-requested a review September 24, 2026 02:31
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bcdxn
bcdxn merged commit e0a79bb into bcdxn:main Sep 29, 2026
3 checks passed
@bcdxn

bcdxn commented Sep 29, 2026

Copy link
Copy Markdown
Owner

merged. Thanks again @bhouston!

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.

Spec has no way to express a required variadic flag/option

4 participants