Documentation
¶
Overview ¶
Package jsoncmd provides the "json" parent command, which groups agent-oriented subcommands that accept structured JSON input on stdin and produce JSON output unconditionally. The package also exports a generic DecodeStdin helper used by all json subcommands to decode typed payloads from stdin.
Index ¶
- func DecodeStdin[T any](r io.Reader) (T, error)
- func NewCmd(f *cmdutil.Factory) *cli.Command
- func RunComment(ctx context.Context, input RunCommentInput) error
- func RunCreate(ctx context.Context, input RunCreateInput) error
- func RunUpdate(ctx context.Context, input RunUpdateInput) error
- type RunCommentInput
- type RunCreateInput
- type RunUpdateInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeStdin ¶
DecodeStdin reads exactly one JSON object from r and decodes it into a value of type T. It rejects unknown fields and trailing content — the input must contain exactly one well-formed JSON object and nothing else.
This is the shared entry point for all json subcommands: each defines its own typed struct and calls DecodeStdin[MyStruct](os.Stdin) to get a fully decoded value with no casting.
func NewCmd ¶
NewCmd constructs the "json" parent command, which groups agent-oriented subcommands that read structured JSON from stdin and write JSON to stdout. The parent command has no action of its own — it exists only to namespace the json subcommands.
All subcommands output JSON unconditionally; there is no --json flag. Identity and context flags (--author, --claim) remain on the command line; the JSON object on stdin provides content fields only.
func RunComment ¶
func RunComment(ctx context.Context, input RunCommentInput) error
RunComment reads a JSON object from stdin, validates it, and adds a comment to the specified issue via the service layer. Output is always JSON.
func RunCreate ¶
func RunCreate(ctx context.Context, input RunCreateInput) error
RunCreate reads a JSON object from stdin, validates it, and creates an issue via the service layer. Output is always JSON.
The role field defaults to "task" when omitted. The claim field in JSON is silently ignored — use WithClaim on RunCreateInput instead. The label_remove field is accepted but ignored (it only applies to updates).
func RunUpdate ¶
func RunUpdate(ctx context.Context, input RunUpdateInput) error
RunUpdate reads a JSON object from stdin, translates it into a driving.UpdateIssueInput, and calls the service directly. The issue ID is resolved from the claim ID — no explicit issue ID is needed.
Field semantics follow JSON PATCH conventions:
- Absent fields: no change.
- Null fields: unset/clear the value.
- Present fields: update to the provided value.
The role and claim fields are accepted for schema compatibility with json create. If role is present and differs from the issue's current role, an error is returned. The claim field is silently ignored.
Output is always JSON.
Types ¶
type RunCommentInput ¶
type RunCommentInput struct {
Service driving.Service
IssueID string
Author string
Stdin io.Reader
WriteTo io.Writer
}
RunCommentInput holds the parameters for the json comment operation, decoupled from CLI flag parsing so it can be tested directly.