add command.Spec and command.Invocation types (PRINFRA-121) - #5
Merged
somanshreddy merged 1 commit intoMar 31, 2026
Conversation
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Mar 31, 2026
somanshreddy
force-pushed
the
03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor
branch
from
March 31, 2026 17:22
09b012f to
9e74e48
Compare
This was referenced Mar 31, 2026
PRINFRA-121 CLI M1: OpenAPI codegen pipeline
Build the code generation pipeline that reads Scope
Mapping Rules
Acceptance Criteria
|
somanshreddy
commented
Mar 31, 2026
somanshreddy
commented
Mar 31, 2026
somanshreddy
commented
Mar 31, 2026
| } | ||
|
|
||
| // PollConfig defines how --wait polling works for async commands. | ||
| type PollConfig struct { |
Collaborator
Author
There was a problem hiding this comment.
TODO: Will work on this in a future PR. Will have a better idea of the data structures then
somanshreddy
commented
Mar 31, 2026
| } | ||
|
|
||
| // Column defines a TUI table column for --human output. | ||
| type Column struct { |
somanshreddy
force-pushed
the
03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor
branch
from
March 31, 2026 21:06
9e74e48 to
bb1119f
Compare
somanshreddy
marked this pull request as ready for review
March 31, 2026 21:10
somanshreddy
force-pushed
the
03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor
branch
from
March 31, 2026 21:25
bb1119f to
1b0e167
Compare
New internal/command package with the core type system for generated commands. Spec is the immutable definition (endpoint, method, flags, args, behavioral metadata). Invocation holds per-run resolved values (path params, query params, body). BuildInvocation handles merge order: --json-body first, then positional args, then flags overlay. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
somanshreddy
force-pushed
the
03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor
branch
from
March 31, 2026 21:55
1b0e167 to
5c35595
Compare
jrusso1020
approved these changes
Mar 31, 2026
Collaborator
Author
Merge activity
|
somanshreddy
deleted the
03-31-add_command.spec_command.invocation_types_generic_builder_refactor_executor
branch
March 31, 2026 22:38
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.

Description
Introduces the two core types that power every CLI command — generated or hand-written.
command.Specis the immutable definition of a command. It describes what the command is: its API endpoint, HTTP method, flags, positional args, and behavioral metadata like pagination. Generated from the OpenAPI spec at build time, never mutated at runtime.command.Invocationis the per-run resolved values — what the user actually typed. Path params, query params, and request body fields. Built fresh each time a command executes.These two types have a hard boundary: Spec holds static metadata, Invocation holds runtime values. No field appears in both. This prevents the kind of drift where transport and presentation concerns get mixed in one struct (which was happening with the old
RequestSpec).-d/--datasupport in BuildInvocation: Some API endpoints require complex input types (discriminated unions, nested objects, arrays of objects) that can't be expressed as CLI flags. Every major CLI has an escape hatch for this — Stripe's-d, gh's--input, AWS's--cli-input-json. Ours is-d/--data. BuildInvocation handles the merge order when-d/--datais combined with flags: -d/--data loads first as the base, then positional args overlay, then flags overlay. Flag wins over -d/--data for the same field. This enables reusable JSON templates with per-invocation flag tweaks.Validation: BuildInvocation validates enum values and int min/max bounds (from the OpenAPI spec) before the API call, returning exit code 2 (usage error) for invalid values.
Testing
15 unit tests covering: query param routing, body field routing, path/body/file positional args, unchanged flags omitted, enum validation (valid + invalid), min/max validation (5 subcases), -d/--data as base, flag overrides -d/--data, positional arg overrides -d/--data, nil body for query-only commands, string-slice flags.
Files
internal/command/spec.go— Spec, Invocation, ArgSpec, FlagSpec, PollConfig, Column types + BuildInvocationinternal/command/spec_test.go— 15 unit tests