patch

package
v4.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package patch applies PR #218's profile/deliver/feedback features to an already-published printing-press CLI without re-rendering its templates.

The patcher works by AST-injecting the cobra wiring into internal/cli/root.go (preserving every existing AddCommand, including novel/synthetic commands) and dropping in three self-contained companion files rendered from templates. It never reads the source spec, never touches per-endpoint command files, and never changes the CLI's module path.

See docs/plans/2026-04-18-001-feat-patch-library-clis-v2-plan.md for the architecture rationale.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collision

type Collision struct {
	Kind    string `json:"kind"`    // "resource", "flag", "command"
	Symbol  string `json:"symbol"`  // e.g. "feedback", "newProfileCmd"
	File    string `json:"file"`    // existing file path that collides, if any
	Message string `json:"message"` // human-readable explanation
}

Collision is a conflict between the patcher's output and an existing symbol or file in the target CLI.

type Options

type Options struct {
	// Dir is the CLI root, e.g. ~/Code/printing-press-library/library/productivity/cal-com
	Dir string
	// DryRun prints the file list without writing anything.
	DryRun bool
	// Force overrides a resource-level collision.
	Force bool
	// SkipBuild skips the post-patch `go build` gate.
	SkipBuild bool
}

Options controls a single Patch run.

type Report

type Report struct {
	Dir           string      `json:"dir"`
	Name          string      `json:"name"`
	FilesCreated  []string    `json:"files_created"`
	FilesModified []string    `json:"files_modified"`
	Collisions    []Collision `json:"collisions,omitempty"`
	Idempotent    bool        `json:"idempotent"`
	BuildOK       bool        `json:"build_ok"`
	BuildOutput   string      `json:"build_output,omitempty"`
	DryRun        bool        `json:"dry_run"`
}

Report captures the outcome of a Patch run.

func Patch

func Patch(opts Options) (*Report, error)

Patch applies PR #218's features to the CLI at opts.Dir and returns a Report. The CLI's own files are only modified when DryRun is false and there are no fatal collisions (unless Force is set).

Jump to

Keyboard shortcuts

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