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

app

package
v1.47.0 Latest Latest
Warning

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

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

Documentation

Overview

Package app owns the CLI invocation lifecycle.

Index

Constants

View Source
const (
	EmptyBody              = requestconfig.EmptyBody
	MultipartFormEncoded   = requestconfig.MultipartFormEncoded
	ApplicationJSON        = requestconfig.ApplicationJSON
	ApplicationOctetStream = requestconfig.ApplicationOctetStream
)
View Source
const (
	OutputUnspecified = transformers.OutputUnspecified
	OutputResponse    = transformers.OutputResponse
	OutputPageItem    = transformers.OutputPageItem
	OutputStreamEvent = transformers.OutputStreamEvent
)
View Source
const Version = "1.47.0" // x-release-please-version

Variables

View Source
var OutputFormats = clioutput.Formats

Temporary forwarding value for the generated runtime bridge.

Functions

func ConfigureCommand added in v1.39.1

func ConfigureCommand(root *cli.Command)

ConfigureCommand installs SDK-owned behavior after the generated command tree is complete.

func ConfigureCommandErrors added in v1.39.1

func ConfigureCommandErrors(root *cli.Command)

ConfigureCommandErrors composes with success wrappers without owning success output. Calling it again after help setup covers newly added local commands without wrapping existing actions or usage handlers twice.

func ConfigureHelp added in v1.39.1

func ConfigureHelp(root *cli.Command, args []string) ([]string, bool, error)

ConfigureHelp decorates help without changing API commands or their defaults.

func FlagOptions added in v1.39.1

func FlagOptions(
	cmd *cli.Command,
	nestedFormat apiquery.NestedQueryFormat,
	arrayFormat apiquery.ArrayQueryFormat,
	bodyType BodyContentType,

	ignoreStdin bool,
	observeJSON ...func([]byte),
) (options []option.RequestOption, err error)

func GetDefaultRequestOptions added in v1.39.1

func GetDefaultRequestOptions(cmd *cli.Command) []option.RequestOption

GetDefaultRequestOptions keeps feature middleware composition with its current owner.

func ImageModelOptions added in v1.39.1

func ImageModelOptions() images.ModelOptions

ImageModelOptions binds discovery to application policy.

func ImagePreviewOptions added in v1.39.1

func ImagePreviewOptions() images.PreviewOptions

ImagePreviewOptions binds local previews to application receipt and error policy.

func ImageSavingOptions added in v1.39.1

func ImageSavingOptions() images.SavingOptions

ImageSavingOptions binds image preparation to application request and diagnostic policy.

func InteractiveListOutput added in v1.39.1

func InteractiveListOutput(opts ShowJSONOpts) bool

InteractiveListOutput leaves explicit machine formats and redirected input or output on their existing iterator path. It never opens a controlling terminal.

func IsLocalUtilityCommand added in v1.39.1

func IsLocalUtilityCommand(command *cli.Command) bool

IsLocalUtilityCommand identifies a registered utility after root flag parsing. Request values and unregistered command names never select the local path.

func NewRequestHeaderFlag added in v1.39.1

func NewRequestHeaderFlag() cli.Flag

NewRequestHeaderFlag forwards the generated runtime bridge to request ownership. Remove this forwarding function when the authoritative generator updates its caller.

func ReportSaveReceipt added in v1.39.1

func ReportSaveReceipt(command *cli.Command, stderr io.Writer, message string, operationErr error) error

ReportSaveReceipt keeps successful save receipts separate from response bytes. Callers use this after completing their work; binary responses use the same policy.

func Run

func Run(ctx context.Context, argv []string, app *cli.Command) int

Run executes one CLI process invocation and returns its exit status. The caller supplies the process-scoped command tree; Run is called once per process.

func RunWithOutputPolicy added in v1.39.1

func RunWithOutputPolicy(ctx context.Context, root *cli.Command, run func(context.Context) error) error

RunWithOutputPolicy reports after the complete CLI run and its cleanup return. Direct Command.Run callers retain the existing action-scoped reporting boundary.

func SetupImagePickerShellOnFirstRun added in v1.39.1

func SetupImagePickerShellOnFirstRun(ctx context.Context, args []string, roots ...*cli.Command)

SetupImagePickerShellOnFirstRun quietly prepares future interactive shells. It does not change the current command, terminal bindings, or exit status. Failures remain optional, and later ordinary runs may safely retry setup.

func ShowCommandError added in v1.39.1

func ShowCommandError(root *cli.Command, failure error, out io.Writer) error

ShowCommandError presents a failure without changing its identity or exit code. Explicit data formats preserve the API payload. Human summaries never echo API prose, request values, URLs or arbitrary local diagnostics. Both renderer sinks use out, including explorer output and warnings. Writer failures are returned.

func ShowCommandErrorFallback added in v1.39.1

func ShowCommandErrorFallback(failure, presentationErr error, out io.Writer) error

ShowCommandErrorFallback keeps secondary cancellation diagnostics bounded too. Its result retains the original presentation failure and any fallback failure.

func ShowJSON added in v1.39.1

func ShowJSON(res gjson.Result, opts ShowJSONOpts) error

ShowJSON displays a single JSON result to the user.

func ShowJSONIterator added in v1.39.1

func ShowJSONIterator[T any](iter jsonview.Iterator[T], itemsToDisplay int64, opts ShowJSONOpts) error

ShowJSONIterator displays an iterator of values to the user. Use itemsToDisplay = -1 for no limit.

func ShowJSONPages added in v1.39.1

func ShowJSONPages[P JSONListPage[P]](first func(context.Context) (P, error), maximum int64, opts ShowJSONOpts, cursorField string) error

ShowJSONPages retains the lazy-page entrypoint with assembly presentation policy.

func ValidateBaseURL added in v1.39.1

func ValidateBaseURL(value, source string) error

ValidateBaseURL forwards scheme validation for the generated runtime bridge.

func WriteBinaryResponse added in v1.39.1

func WriteBinaryResponse(response *http.Response, stdout io.Writer, outfile string) (message string, err error)

WriteBinaryResponse writes a binary response to stdout or a file.

Takes in a stdout reference so we can test this function without overriding os.Stdout in tests.

Types

type BodyContentType added in v1.39.1

type BodyContentType = requestconfig.BodyContentType

Temporary aliases for the generated runtime bridge. Migrate generated callers through their producer before removing these names.

type JSONListPage added in v1.39.1

type JSONListPage[P any] = listview.JSONListPage[P]

JSONListPage is implemented by SDK explicit API page types.

type OutputKind added in v1.39.1

type OutputKind = transformers.OutputKind

type ShowJSONOpts added in v1.39.1

type ShowJSONOpts struct {
	Context        context.Context // request cancellation; defaults to context.Background()
	Operation      string          // generated operation identifier; empty for error presentation
	OutputKind     OutputKind      // response, page item, or stream event; unspecified for errors
	ExplicitFormat bool            // true if the user explicitly passed --format
	Format         string          // output format (auto, text, explore, json, jsonl, pretty, raw, yaml)
	RawOutput      bool            // like jq -r: print strings without JSON quotes
	Stderr         io.Writer       // stderr for warnings; injectable for testing; defaults to os.Stderr
	Stdout         io.Writer       // output destination; defaults to os.Stdout
	Title          string          // display title
	Transform      string          // GJSON path to extract before displaying

	// The caller cancels Context on signals, so the explorer must not also handle them.
	CallerHandlesSignals bool
}

ShowJSONOpts configures how JSON output is displayed.

Jump to

Keyboard shortcuts

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