Help us shape the future of Go! Take the 2026 Go Developer Survey

images

package
v1.45.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Overview

Package images owns handwritten image workflows, saving, previews, and picker state.

Index

Constants

View Source
const PreviewDetails = `` /* 359-byte string literal not displayed */

PreviewDetails is shared by preview command and onboarding help.

Variables

This section is empty.

Functions

func ConfigureCompletion

func ConfigureCompletion(root *cli.Command)

ConfigureCompletion keeps the optional current-session hook on the existing completion command.

func ConfigureSaving

func ConfigureSaving(root *cli.Command, opts SavingOptions)

ConfigureSaving decorates the generated image commands with shared saving behavior. Model discovery and terminal rendering have separate owners.

func ConfigureShellSetup

func ConfigureShellSetup(root *cli.Command, receipt func(context.Context, string) error)

ConfigureShellSetup keeps completion generation and persistent picker setup on the existing completion command, without changing the generated command definition.

func ConsumeSavingRequest

func ConsumeSavingRequest(command *cli.Command, nested apiquery.NestedQueryFormat, array apiquery.ArrayQueryFormat, body requestconfig.BodyContentType, ignoreStdin bool) ([]option.RequestOption, bool, error)

ConsumeSavingRequest returns one prepared request to its generated handler.

func FirstRunEligible

func FirstRunEligible(args []string, getenv func(string) string, inputTTY, outputTTY, errorTTY bool, shell string) bool

FirstRunEligible checks shell and invocation eligibility without consuming arguments.

func IsImagePickerShellSetupCommand

func IsImagePickerShellSetupCommand(args []string) bool

IsImagePickerShellSetupCommand recognizes explicit local setup in the root's remaining arguments, after global flags have been parsed. Setup validates its own options before changing files. API argument values never qualify.

func ObserveMultipart

func ObserveMultipart(command *cli.Command, body io.Closer)

ObserveMultipart retains the encoded body for cleanup if dispatch fails early.

func PrepareMultipartBody

func PrepareMultipartBody(command *cli.Command, body map[string]any) error

PrepareMultipartBody inspects merged scalar settings after trusted file expansion, before the existing multipart encoder takes ownership. Source images and masks remain streamed and are never decoded, buffered, or rewritten here.

func RegisterModels

func RegisterModels(root *cli.Command, opts ModelOptions)

RegisterModels installs image model discovery, a CLI workflow over the existing model retrieval operation. Keep generated /models listing and its script contract untouched.

func RegisterPreview

func RegisterPreview(root *cli.Command, opts PreviewOptions)

RegisterPreview installs local previews and inline preference commands.

func SetupShellOnFirstRun

func SetupShellOnFirstRun(ctx context.Context, args []string)

SetupShellOnFirstRun performs optional setup after assembly admits a background worker.

func ShowSavedResponse

func ShowSavedResponse(ctx context.Context, res []byte) (bool, error)

ShowSavedResponse handles a response selected by application routing.

func ShowSavedStream

func ShowSavedStream[T any](ctx context.Context, source jsonview.Iterator[T], quiet bool) (bool, error)

ShowSavedStream handles a stream selected by application routing, retaining stream cleanup ownership.

Types

type ModelOptions

type ModelOptions struct {
	RequestOptions        RequestOptions
	DefaultRequestOptions func(*cli.Command) []option.RequestOption
	HumanOutput           func(*cli.Command) bool
	DiagnosticsAllowed    func(context.Context) bool
	ShowData              func(context.Context, *cli.Command, gjson.Result, io.Writer) error
}

ModelOptions connects image model discovery to application request and output policy.

type ModelsError

type ModelsError struct {
	// contains filtered or unexported fields
}

ModelsError keeps discovery's local guidance identifiable without retaining API errors or rejected arguments. Only failure categories and the local help invocation contribute to its message.

func (*ModelsError) Error

func (e *ModelsError) Error() string

func (*ModelsError) ReadableMessage added in v1.40.3

func (e *ModelsError) ReadableMessage(command *cli.Command, output ...io.Writer) string

ReadableMessage registers recovery commands only for readable output.

type PreviewOptions

type PreviewOptions struct {
	Receipt          func(context.Context, string) error
	SuggestedReceipt func(context.Context, *cli.Command, string, []string) error
	ShowError        func(*cli.Command, error, io.Writer) error
}

PreviewOptions connects local previews to receipt and error presentation.

type RequestOptions

RequestOptions prepares a generated request using assembly-owned hooks.

type SavingError

type SavingError struct {
	// contains filtered or unexported fields
}

A private classification carries locally authored guidance through the shared error presenter. Causes remain available to errors.Is without printing data.

func (*SavingError) Error

func (e *SavingError) Error() string

func (*SavingError) PreserveOnCancel

func (e *SavingError) PreserveOnCancel() bool

PreserveOnCancel retains guidance about files already saved before cancellation.

func (*SavingError) ReadableMessage added in v1.40.3

func (e *SavingError) ReadableMessage(command *cli.Command, output ...io.Writer) string

ReadableMessage registers only explicitly authored recovery commands.

func (*SavingError) Unwrap

func (e *SavingError) Unwrap() error

type SavingOptions

type SavingOptions struct {
	RequestOptions     RequestOptions
	DiagnosticsAllowed func(context.Context) bool
	ErrorFormat        func(*cli.Command) string
}

SavingOptions supplies policy while the feature owns preparation and image lifetime.

Jump to

Keyboard shortcuts

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