jsoncmd

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeStdin

func DecodeStdin[T any](r io.Reader) (T, error)

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

func NewCmd(f *cmdutil.Factory) *cli.Command

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. Unknown fields are rejected by the JSON decoder.

When Deferred is true, the issue is created with an internal claim, deferred using that claim, and the claim is consumed. The output reflects the deferred state with no claim_id. The --deferred and --with-claim flags are mutually exclusive.

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 field is accepted for schema compatibility with json create: if present and differs from the issue's current role, an error is returned. Unknown fields are rejected by the JSON decoder.

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.

type RunCreateInput

type RunCreateInput struct {
	Service   driving.Service
	Author    string
	Stdin     io.Reader
	WriteTo   io.Writer
	WithClaim bool
	Deferred  bool
}

RunCreateInput holds the parameters for the json create operation, decoupled from CLI flag parsing so it can be tested directly.

type RunUpdateInput

type RunUpdateInput struct {
	Service driving.Service
	ClaimID string
	Stdin   io.Reader
	WriteTo io.Writer
}

RunUpdateInput holds the parameters for the json update operation, decoupled from CLI flag parsing so it can be tested directly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL