package formatter
import "github.com/docker/compose/v2/cmd/formatter"
Index ¶
- Constants
- func ClearLine()
- func ContainerWrite(ctx formatter.Context, containers []api.ContainerSummary) error
- func HideCursor()
- func MoveCursor(y, x int)
- func MoveCursorDown(lines int)
- func MoveCursorUp(lines int)
- func MoveCursorX(pos int)
- func NewContainerFormat(source string, quiet bool, size bool) formatter.Format
- func NewKeyboardManager(ctx context.Context, isDockerDesktopActive, isWatchConfigured bool, sc chan<- os.Signal, watchFn func(ctx context.Context, doneCh chan bool, project *types.Project, services []string, options api.WatchOptions, ) error, )
- func NewLine()
- func NewLogConsumer(ctx context.Context, stdout, stderr io.Writer, color, prefix, timestamp bool) api.LogConsumer
- func Print(toJSON interface{}, format string, outWriter io.Writer, writerFn func(w io.Writer), headers ...string) error
- func PrintPrettySection(out io.Writer, printer func(writer io.Writer), headers ...string) error
- func RestoreCursor()
- func SaveCursor()
- func SetANSIMode(streams command.Streams, ansi string)
- func SetMultiErrorFormat(errs *multierror.Error)
- func ShowCursor()
- func ToJSON(i interface{}, prefix string, indentation string) (string, error)
- func ToStandardJSON(i interface{}) (string, error)
- type ContainerContext
- func NewContainerContext() *ContainerContext
- func (c *ContainerContext) Command() string
- func (c *ContainerContext) CreatedAt() string
- func (c *ContainerContext) ExitCode() int
- func (c *ContainerContext) Health() string
- func (c *ContainerContext) ID() string
- func (c *ContainerContext) Image() string
- func (c *ContainerContext) Label(name string) string
- func (c *ContainerContext) Labels() string
- func (c *ContainerContext) LocalVolumes() string
- func (c *ContainerContext) MarshalJSON() ([]byte, error)
- func (c *ContainerContext) Mounts() string
- func (c *ContainerContext) Name() string
- func (c *ContainerContext) Names() string
- func (c *ContainerContext) Networks() string
- func (c *ContainerContext) Ports() string
- func (c *ContainerContext) Project() string
- func (c *ContainerContext) Publishers() api.PortPublishers
- func (c *ContainerContext) RunningFor() string
- func (c *ContainerContext) Service() string
- func (c *ContainerContext) Size() string
- func (c *ContainerContext) State() string
- func (c *ContainerContext) Status() string
- type KEYBOARD_LOG_LEVEL
- type KeyboardError
- type KeyboardWatch
- type LogKeyboard
- func (lk *LogKeyboard) ClearKeyboardInfo()
- func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Context, doneCh chan bool, project *types.Project, options api.UpOptions)
- func (lk *LogKeyboard) PrintKeyboardInfo()
- func (lk *LogKeyboard) StartWatch(ctx context.Context, doneCh chan bool, project *types.Project, options api.UpOptions)
Constants ¶
const ( BOLD = "1" FAINT = "2" ITALIC = "3" UNDERLINE = "4" )
const ( RESET = "0" CYAN = "36" )
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" )
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" )
const DISPLAY_ERROR_TIME = 10
Functions ¶
func ClearLine ¶
func ClearLine()
func ContainerWrite ¶
func ContainerWrite(ctx formatter.Context, containers []api.ContainerSummary) error
ContainerWrite renders the context for a list of containers
func HideCursor ¶
func HideCursor()
func MoveCursor ¶
func MoveCursor(y, x int)
func MoveCursorDown ¶
func MoveCursorDown(lines int)
func MoveCursorUp ¶
func MoveCursorUp(lines int)
func MoveCursorX ¶
func MoveCursorX(pos int)
func NewContainerFormat ¶
NewContainerFormat returns a Format for rendering using a Context
func NewKeyboardManager ¶
func NewKeyboardManager(ctx context.Context, isDockerDesktopActive, isWatchConfigured bool, sc chan<- os.Signal, watchFn func(ctx context.Context, doneCh chan bool, project *types.Project, services []string, options api.WatchOptions, ) error, )
func NewLine ¶
func NewLine()
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 ¶
PrintPrettySection prints a tabbed section on the writer parameter
func RestoreCursor ¶
func RestoreCursor()
func SaveCursor ¶
func SaveCursor()
func SetANSIMode ¶
SetANSIMode configure formatter for colored output on ANSI-compliant console
func SetMultiErrorFormat ¶
func SetMultiErrorFormat(errs *multierror.Error)
SetMultiErrorFormat set cli default format for multi-errors
func ShowCursor ¶
func ShowCursor()
func ToJSON ¶
ToJSON return a string with the JSON representation of the interface{}
func ToStandardJSON ¶
ToStandardJSON return a string with the JSON representation of the interface{}
Types ¶
type ContainerContext ¶
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 ¶
func NewContainerContext() *ContainerContext
NewContainerContext creates a new context for rendering containers
func (*ContainerContext) Command ¶
func (c *ContainerContext) Command() string
func (*ContainerContext) CreatedAt ¶
func (c *ContainerContext) CreatedAt() string
func (*ContainerContext) ExitCode ¶
func (c *ContainerContext) ExitCode() int
func (*ContainerContext) Health ¶
func (c *ContainerContext) Health() string
func (*ContainerContext) ID ¶
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 ¶
func (c *ContainerContext) Image() string
func (*ContainerContext) Label ¶
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 ¶
func (c *ContainerContext) Labels() string
Labels returns a comma-separated string of labels present on the container.
func (*ContainerContext) LocalVolumes ¶
func (c *ContainerContext) LocalVolumes() string
LocalVolumes returns the number of volumes using the "local" volume driver.
func (*ContainerContext) MarshalJSON ¶
func (c *ContainerContext) MarshalJSON() ([]byte, error)
MarshalJSON makes ContainerContext implement json.Marshaler
func (*ContainerContext) Mounts ¶
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 ¶
func (c *ContainerContext) Name() string
func (*ContainerContext) Names ¶
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 ¶
func (c *ContainerContext) Networks() string
Networks returns a comma-separated string of networks that the container is attached to.
func (*ContainerContext) Ports ¶
func (c *ContainerContext) Ports() string
func (*ContainerContext) Project ¶
func (c *ContainerContext) Project() string
func (*ContainerContext) Publishers ¶
func (c *ContainerContext) Publishers() api.PortPublishers
func (*ContainerContext) RunningFor ¶
func (c *ContainerContext) RunningFor() string
func (*ContainerContext) Service ¶
func (c *ContainerContext) Service() string
func (*ContainerContext) Size ¶
func (c *ContainerContext) Size() string
Size returns the container's size and virtual size (e.g. "2B (virtual 21.5MB)")
func (*ContainerContext) State ¶
func (c *ContainerContext) State() string
func (*ContainerContext) Status ¶
func (c *ContainerContext) Status() string
type KEYBOARD_LOG_LEVEL ¶
type KEYBOARD_LOG_LEVEL int
const ( NONE KEYBOARD_LOG_LEVEL = 0 INFO KEYBOARD_LOG_LEVEL = 1 DEBUG KEYBOARD_LOG_LEVEL = 2 )
type KeyboardError ¶
type KeyboardError struct {
// contains filtered or unexported fields
}
type KeyboardWatch ¶
type KeyboardWatch struct { Watcher watch.Notify Watching bool WatchFn func(ctx context.Context, doneCh chan bool, project *types.Project, services []string, options api.WatchOptions) error Ctx context.Context Cancel context.CancelFunc }
type LogKeyboard ¶
type LogKeyboard struct { Watch KeyboardWatch IsDockerDesktopActive bool IsWatchConfigured bool // contains filtered or unexported fields }
var ( KeyboardManager *LogKeyboard )
func (*LogKeyboard) ClearKeyboardInfo ¶
func (lk *LogKeyboard) ClearKeyboardInfo()
func (*LogKeyboard) HandleKeyEvents ¶
func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Context, doneCh chan bool, project *types.Project, options api.UpOptions)
func (*LogKeyboard) PrintKeyboardInfo ¶
func (lk *LogKeyboard) PrintKeyboardInfo()
func (*LogKeyboard) StartWatch ¶
func (lk *LogKeyboard) StartWatch(ctx context.Context, doneCh chan bool, project *types.Project, options api.UpOptions)
Source Files ¶
ansi.go colors.go consts.go container.go formatter.go json.go logs.go multierrformat.go pretty.go shortcut.go
- Version
- v2.35.1 (latest)
- Published
- Apr 17, 2025
- Platform
- linux/amd64
- Imports
- 30 packages
- Last checked
- 20 hours ago –
Tools for package owners.