show

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package show provides the generic show command shared by every provider.

The scaffolding here owns the control flow that is identical across providers: argument validation, the --raw/--output=json mutual-exclusion check, pager gating, and the raw/json/text dispatch. Everything that differs between providers — the version-spec grammar, the parse-json rules, and the exact metadata field layout / JSON shape — lives behind the Presenter, so each provider reproduces its own byte-identical output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command[S any](cfg Config[S]) *cli.Command

Command returns the generic show command wired with the provider Config.

Types

type Config

type Config[S any] struct {
	// Usage is the one-line command usage string.
	Usage string
	// ArgsUsage is the positional-arguments usage string.
	ArgsUsage string
	// Description is the long help text.
	Description string
	// UsageError is returned when the resource name argument is missing.
	UsageError string
	// ParseSpec parses the raw name argument into the provider's version spec.
	ParseSpec func(arg string) (S, error)
	// NewPresenter builds the provider Presenter bound to the parsed spec (this
	// is where the provider constructs its AWS client and usecase).
	NewPresenter func(ctx context.Context, spec S) (Presenter, error)
}

Config holds the provider-specific configuration for the show command.

type Options

type Options struct {
	ParseJSON bool
	NoPager   bool
	Raw       bool
	Output    output.Format
}

Options holds the shared show options.

type Presenter

type Presenter interface {
	// Fetch resolves the version spec and loads the entry via the provider usecase.
	Fetch(ctx context.Context) error
	// Value returns the display value. When parseJSON is set it applies the
	// provider's parse-json rules (which may warn to stderr) and records internal
	// state used by the render methods.
	Value(parseJSON bool, stderr io.Writer) string
	// RenderText writes the metadata block followed by the value.
	RenderText(stdout io.Writer, value string)
	// RenderJSON writes the provider-specific JSON output.
	RenderJSON(stdout io.Writer, value string) error
}

Presenter renders a single show result for a specific provider. Implementations are stateful: Fetch loads the entry, and the subsequent methods render it.

type Runner

type Runner struct {
	Presenter Presenter
	Options   Options
	Stdout    io.Writer
	Stderr    io.Writer
}

Runner executes the show command over a provider Presenter.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

Run executes the show command.

Jump to

Keyboard shortcuts

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