formatter

package
v2.40.3 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: Apache-2.0 Imports: 28 Imported by: 23

Documentation

Index

Constants

View Source
const (
	BOLD      = "1"
	FAINT     = "2"
	ITALIC    = "3"
	UNDERLINE = "4"
)
View Source
const (
	RESET = "0"
	CYAN  = "36"
)
View Source
const (
	// Never use ANSI codes
	Never = "never"

	// Always use ANSI codes
	Always = "always"

	// Auto detect terminal is a tty and can use ANSI codes
	Auto = "auto"
)
View Source
const (
	// JSON Print in JSON format
	JSON = "json"
	// TemplateLegacyJSON the legacy json formatting value using go template
	TemplateLegacyJSON = "{{json.}}"
	// PRETTY is the constant for default formats on list commands
	// Deprecated: use TABLE
	PRETTY = "pretty"
	// TABLE Print output in table format with column headers (default)
	TABLE = "table"
)
View Source
const DISPLAY_ERROR_TIME = 10

Variables

This section is empty.

Functions

func ContainerWrite added in v2.21.0

func ContainerWrite(ctx formatter.Context, containers []api.ContainerSummary) error

ContainerWrite renders the context for a list of containers

func NewContainerFormat added in v2.21.0

func NewContainerFormat(source string, quiet bool, size bool) formatter.Format

NewContainerFormat returns a Format for rendering using a Context

func NewLogConsumer

func NewLogConsumer(ctx context.Context, stdout, stderr io.Writer, color, prefix, timestamp bool) api.LogConsumer

NewLogConsumer creates a new LogConsumer

func Print

func Print(toJSON interface{}, format string, outWriter io.Writer, writerFn func(w io.Writer), headers ...string) error

Print prints formatted lists in different formats

func PrintPrettySection

func PrintPrettySection(out io.Writer, printer func(writer io.Writer), headers ...string) error

PrintPrettySection prints a tabbed section on the writer parameter

func SetANSIMode

func SetANSIMode(streams command.Streams, ansi string)

SetANSIMode configure formatter for colored output on ANSI-compliant console

func ToJSON

func ToJSON(i interface{}, prefix string, indentation string) (string, error)

ToJSON return a string with the JSON representation of the interface{}

func ToStandardJSON

func ToStandardJSON(i interface{}) (string, error)

ToStandardJSON return a string with the JSON representation of the interface{}

Types

type ContainerContext added in v2.21.0

type ContainerContext struct {
	formatter.HeaderContext

	// FieldsUsed is used in the pre-processing step to detect which fields are
	// used in the template. It's currently only used to detect use of the .Size
	// field which (if used) automatically sets the '--size' option when making
	// the API call.
	FieldsUsed map[string]interface{}
	// contains filtered or unexported fields
}

ContainerContext is a struct used for rendering a list of containers in a Go template.

func NewContainerContext added in v2.21.0

func NewContainerContext() *ContainerContext

NewContainerContext creates a new context for rendering containers

func (*ContainerContext) Command added in v2.21.0

func (c *ContainerContext) Command() string

func (*ContainerContext) CreatedAt added in v2.21.0

func (c *ContainerContext) CreatedAt() string

func (*ContainerContext) ExitCode added in v2.21.0

func (c *ContainerContext) ExitCode() int

func (*ContainerContext) Health added in v2.21.0

func (c *ContainerContext) Health() string

func (*ContainerContext) ID added in v2.21.0

func (c *ContainerContext) ID() string

ID returns the container's ID as a string. Depending on the `--no-trunc` option being set, the full or truncated ID is returned.

func (*ContainerContext) Image added in v2.21.0

func (c *ContainerContext) Image() string

func (*ContainerContext) Label added in v2.21.0

func (c *ContainerContext) Label(name string) string

Label returns the value of the label with the given name or an empty string if the given label does not exist.

func (*ContainerContext) Labels added in v2.21.0

func (c *ContainerContext) Labels() string

Labels returns a comma-separated string of labels present on the container.

func (*ContainerContext) LocalVolumes added in v2.21.0

func (c *ContainerContext) LocalVolumes() string

LocalVolumes returns the number of volumes using the "local" volume driver.

func (*ContainerContext) MarshalJSON added in v2.21.0

func (c *ContainerContext) MarshalJSON() ([]byte, error)

MarshalJSON makes ContainerContext implement json.Marshaler

func (*ContainerContext) Mounts added in v2.21.0

func (c *ContainerContext) Mounts() string

Mounts returns a comma-separated string of mount names present on the container. If the trunc option is set, names can be truncated (ellipsized).

func (*ContainerContext) Name added in v2.21.0

func (c *ContainerContext) Name() string

func (*ContainerContext) Names added in v2.21.0

func (c *ContainerContext) Names() string

Names returns a comma-separated string of the container's names, with their slash (/) prefix stripped. Additional names for the container (related to the legacy `--link` feature) are omitted.

func (*ContainerContext) Networks added in v2.21.0

func (c *ContainerContext) Networks() string

Networks returns a comma-separated string of networks that the container is attached to.

func (*ContainerContext) Ports added in v2.21.0

func (c *ContainerContext) Ports() string

func (*ContainerContext) Project added in v2.24.0

func (c *ContainerContext) Project() string

func (*ContainerContext) Publishers added in v2.21.0

func (c *ContainerContext) Publishers() api.PortPublishers

func (*ContainerContext) RunningFor added in v2.21.0

func (c *ContainerContext) RunningFor() string

func (*ContainerContext) Service added in v2.21.0

func (c *ContainerContext) Service() string

func (*ContainerContext) Size added in v2.21.0

func (c *ContainerContext) Size() string

Size returns the container's size and virtual size (e.g. "2B (virtual 21.5MB)")

func (*ContainerContext) State added in v2.21.0

func (c *ContainerContext) State() string

func (*ContainerContext) Status added in v2.21.0

func (c *ContainerContext) Status() string

type Feature added in v2.38.2

type Feature interface {
	Start(context.Context) error
	Stop() error
}

Feature is an compose feature that can be started/stopped by a menu command

type KEYBOARD_LOG_LEVEL added in v2.26.0

type KEYBOARD_LOG_LEVEL int
const (
	NONE  KEYBOARD_LOG_LEVEL = 0
	INFO  KEYBOARD_LOG_LEVEL = 1
	DEBUG KEYBOARD_LOG_LEVEL = 2
)

type KeyboardError added in v2.26.0

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

type KeyboardWatch added in v2.26.0

type KeyboardWatch struct {
	Watching bool
	Watcher  Feature
}

type LogKeyboard added in v2.26.0

type LogKeyboard struct {
	Watch                 *KeyboardWatch
	IsDockerDesktopActive bool
	// contains filtered or unexported fields
}

func NewKeyboardManager added in v2.26.0

func NewKeyboardManager(isDockerDesktopActive bool, sc chan<- os.Signal) *LogKeyboard

func (*LogKeyboard) Decorate added in v2.38.2

func (lk *LogKeyboard) Decorate(l api.LogConsumer) api.LogConsumer

func (*LogKeyboard) EnableWatch added in v2.38.2

func (lk *LogKeyboard) EnableWatch(enabled bool, watcher Feature)

func (*LogKeyboard) HandleKeyEvents added in v2.26.0

func (lk *LogKeyboard) HandleKeyEvents(ctx context.Context, event keyboard.KeyEvent, project *types.Project, options api.UpOptions)

func (*LogKeyboard) PrintKeyboardInfo added in v2.26.0

func (lk *LogKeyboard) PrintKeyboardInfo()

func (*LogKeyboard) ToggleWatch added in v2.37.0

func (lk *LogKeyboard) ToggleWatch(ctx context.Context, options api.UpOptions)

Jump to

Keyboard shortcuts

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