tableprinter

package
v0.7.0-92-ged02f18 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. Licensed under the BSD-3-Clause License (the "License"). You may not use this file expect in compliance with the License.

Index

Constants

View Source
const (
	OutputFormatTable = TableOutputFormat("table")
	OutputFormatJSON  = TableOutputFormat("json")
	OutputFormatYAML  = TableOutputFormat("yaml")

	DefaultDelimeter = "  "
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Column added in v0.7.0

type Column struct {
	Name  string
	Value string
}

Column represents a column name in a table.

type TableField added in v0.6.1

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

func (*TableField) DisplayWidth added in v0.6.1

func (f *TableField) DisplayWidth() int

type TableOutputFormat added in v0.6.1

type TableOutputFormat string

type TablePrinter

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

func NewTablePrinter

func NewTablePrinter(ctx context.Context, topts ...TablePrinterOption) (*TablePrinter, error)

NewTablePrinter returns a pointer instance of TablePrinter struct.

func (*TablePrinter) AddField

func (printer *TablePrinter) AddField(s string, colorFunc func(string) string)

AddField adds a new field to the table.

func (*TablePrinter) EndRow

func (printer *TablePrinter) EndRow()

EndRow ends the current row.

func (*TablePrinter) Render

func (printer *TablePrinter) Render(w io.Writer) error

type TablePrinterOption added in v0.6.1

type TablePrinterOption func(*TablePrinter) error

TablePrinterOption is a type of func(*TablePrinter).

func WithFieldTruncateFunc added in v0.6.1

func WithFieldTruncateFunc(truncateFunc func(int, string) string) TablePrinterOption

WithFieldTruncateFunc returns a function func(opts *TablePrinter) that sets `truncateFunc` in TablePrinter pointer instance.

func WithMaxWidth added in v0.6.1

func WithMaxWidth(maxWidth int) TablePrinterOption

WithMaxWidth returns a function func(opts *TablePrinter) that sets `maxWidth` in TablePrinter pointer instance.

func WithOutputFormat added in v0.6.1

func WithOutputFormat(format TableOutputFormat) TablePrinterOption

WithOutputFormat returns a function func(opts *TablePrinter) that sets `format` in TablePrinter pointer instance.

func WithOutputFormatFromString added in v0.6.1

func WithOutputFormatFromString(format string) TablePrinterOption

WithOutputFormatFromString returns a function func(opts *TablePrinter) that sets `format` in TablePrinter pointer instance of type `TableOutputFormat` from string.

func WithTableDelimeter added in v0.6.1

func WithTableDelimeter(delim string) TablePrinterOption

WithTableDelimeter returns a function func(opts *TablePrinter) that sets `delimeter` in TablePrinter pointer instance.

Jump to

Keyboard shortcuts

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