feat(cli): positional <id> args for generated commands#50
Merged
Conversation
Generated commands were flag/--data-only, which blocked removing the curated ID-based shadows (incident/alert verbs) without ergonomic regression. Add positional-argument support in the generator: a generated command whose request has a required *_id (scalar) or *_ids (array) body field now accepts that id positionally (folded onto the existing flag at runtime; the flag and --data still work and take precedence). - Selection: required *_id/*_ids, array-wins, with a per-op override map (incident merge -> target_incident_id; war-room detail/add-member -> chat_id). - Suppress positional on `create` verbs (the required id is a parent ref) and on rule-move (its rule-ids field is `ids`, not `*_ids`). - Scalar positionals require exactly one arg; arrays require >=1; friendly errors mirror curated requireArgs (new requireExactArg sibling). - intslice fold for []uint64 id fields (team_ids/person_ids/role_ids/...). - gen_support.go genFoldPositional helper; selectPositional unit-tested. 123 positionals across 250 generated commands; non-breaking (no curated command behavior changed); live-verified on testback. Foundation for dropping the clean curated ID-verb shadows in a reviewed follow-up.
ysyneu
added a commit
that referenced
this pull request
Jun 15, 2026
…re-rename shadows, #50 positional args
ysyneu
added a commit
that referenced
this pull request
Jun 15, 2026
feat(cli): drop transparent curated ID-verb shadows (parity via #50)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Generated OpenAPI commands were flag/
--data-only (no positional args), while curated commands accept<id> [<id2>...]. That gap blocks the next stage of the generated-single-source convergence: the curated ID-based shadows (incident/alert verbs) can't be dropped without ergonomic regression.This adds positional-argument capability to the generator. Non-breaking — it adds an optional positional onto generated commands; it removes/modifies no curated command. Foundation for a reviewed follow-up that drops the clean ID-verb shadows.
How
A generated command whose request has a required
*_id(scalar) or*_ids(array) body field now accepts that id positionally. The positional is folded onto the existing flag at runtime — the flag and--datastill work, with precedence--flag > positional > --data.*_id/*_ids, array-wins, with a per-op override map (incident merge → target_incident_id;war-room detail/add-member → chat_id).createverbs (the required id is a parent ref liketeam_id, not the resource identity) andrule-move(its rule-ids field isids, not*_ids).requireExactArg); array →>=1(requireArgs). Friendly errors mirror curated (missing X/expects exactly one X/invalid X: must be an integer).genFoldPositionalhandles string scalar, string slice, int scalar (schedule_id), andintslicefor[]uint64id fields (team_ids/person_ids/role_ids/…) — a naive string fold breaksgenBindBodyfor these.123 positionals emitted across 250 generated commands (96 scalar + 27 array, post-suppression).
Verify
go build -tags=jsoniter ./...clean;go test -tags=jsoniter ./...all pass (incl. structuralflag_consistency_test.go).TestSelectPositional(override / array-wins / scalar / ambiguous→none / create-suppress / empty-override) + runtime fold tests (string/slice/int/intslice/flag-overrides-positional).team infos <team-id>([]uint64fold) returns real data;incident info a b→expects exactly one incident_id;schedule info abc→invalid schedule_id: must be an integer;channel create --helphas no positional.zz_generated_*, theargs.go/gen_support.goshared helpers, a mechanicalmonit_agent.gocallback-signature update, and tests — no curated command behavior changed.Quality gates
/simplify --uncommitted(3 refactors: unused param, intermediate map, error-through-callback) +/review-to-main --uncommitted(no critical bugs; all 4 warnings + the unit-test gap folded in here).