components

package
v0.0.0-...-1bd9ace Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusErr

func StatusErr(pad int) string

StatusErr prints out the default Err symbol, center padded to the size specified.

func StatusOK

func StatusOK(pad int) string

StatusOK prints out the default OK symbol, center padded to the size specified.

func YNPrompt

func YNPrompt(message string, defaultValue bool) bool

YNPrompt is a helper function that prompts the user for a Y/N response.

Types

type CSVStreamWriter

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

CSVStreamWriter writes data in CSV format.

func NewCSVStreamWriter

func NewCSVStreamWriter(w io.Writer) *CSVStreamWriter

NewCSVStreamWriter creates a CSVStreamWriter.

func (*CSVStreamWriter) Finish

func (c *CSVStreamWriter) Finish()

Finish is called to flush all the data.

func (*CSVStreamWriter) SetHeader

func (c *CSVStreamWriter) SetHeader(id string, headerValues []string)

SetHeader is called to set the key values for each of the data values. Must be called before Write is.

func (*CSVStreamWriter) Write

func (c *CSVStreamWriter) Write(data []interface{}) error

Write is called for each record of data.

type InputField

type InputField struct {
	*tview.Box
	// contains filtered or unexported fields
}

InputField is a one-line box which scrolls. This is copied from https://github.com/rivo/tview/blob/e352ec01560d2efc19918e4732310255b2bb800a/inputfield.go and modified to expose cursor position and more custom event handling. The following keys can be used for navigation and editing:

  • Left arrow: Move left by one character.
  • Right arrow: Move right by one character.
  • Home, Ctrl-A, Alt-a: Move to the beginning of the line.
  • End, Ctrl-E, Alt-e: Move to the end of the line.
  • Alt-left, Alt-b: Move left by one word.
  • Alt-right, Alt-f: Move right by one word.
  • Backspace: Delete the character before the cursor.
  • Delete: Delete the character after the cursor.
  • Ctrl-K: Delete from the cursor to the end of the line.
  • Ctrl-W: Delete the last word before the cursor.
  • Ctrl-U: Delete the entire line.

func NewInputField

func NewInputField() *InputField

NewInputField returns a new input field.

func (*InputField) Draw

func (i *InputField) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*InputField) Focus

func (i *InputField) Focus(func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*InputField) GetCursorPos

func (i *InputField) GetCursorPos() int

GetCursorPos gets the current cursor position.

func (*InputField) GetText

func (i *InputField) GetText() string

GetText returns the current text of the input field.

func (*InputField) InputHandler

func (i *InputField) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns the handler for this primitive.

func (*InputField) MouseHandler

func (i *InputField) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (bool, tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*InputField) SetChangedFunc

func (i *InputField) SetChangedFunc(handler func(text string)) *InputField

SetChangedFunc sets a handler which is called whenever the text of the input field has changed. It receives the current text (after the change).

func (*InputField) SetCursorPos

func (i *InputField) SetCursorPos(p int)

SetCursorPos sets the current cursor position.

func (*InputField) SetFieldBackgroundColor

func (i *InputField) SetFieldBackgroundColor(color tcell.Color) *InputField

SetFieldBackgroundColor sets the background color of the input area.

func (*InputField) SetFieldTextColor

func (i *InputField) SetFieldTextColor(color tcell.Color) *InputField

SetFieldTextColor sets the text color of the input area.

func (*InputField) SetPlaceholderTextColor

func (i *InputField) SetPlaceholderTextColor(color tcell.Color) *InputField

SetPlaceholderTextColor sets the text color of placeholder text.

func (*InputField) SetText

func (i *InputField) SetText(text string, textColors map[int]tcell.Color, triggerChange bool) *InputField

SetText sets the current text of the input field.

type JSONStreamWriter

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

JSONStreamWriter writes one json record per row.

func NewJSONStreamWriter

func NewJSONStreamWriter(w io.Writer) *JSONStreamWriter

NewJSONStreamWriter creates a JSONStreamWriter

func (*JSONStreamWriter) Finish

func (j *JSONStreamWriter) Finish()

Finish is called to flush all the data.

func (*JSONStreamWriter) SetHeader

func (j *JSONStreamWriter) SetHeader(id string, headerValues []string)

SetHeader is called to set the key values for each of the data values. Must be called before Write is.

func (*JSONStreamWriter) Write

func (j *JSONStreamWriter) Write(data []interface{}) error

Write is called for each record of data.

type MapItem

type MapItem struct {
	Key, Value interface{}
}

MapItem is a key, value pain.

type MapSlice

type MapSlice []MapItem

MapSlice is an array of items.

func (MapSlice) MarshalJSON

func (ms MapSlice) MarshalJSON() ([]byte, error)

MarshalJSON marshals the k/v array in order.

type NullStreamWriter

type NullStreamWriter struct{}

NullStreamWriter reads the data but does not output it.

func (*NullStreamWriter) Finish

func (*NullStreamWriter) Finish()

Finish is called to flush all the data.

func (*NullStreamWriter) SetHeader

func (*NullStreamWriter) SetHeader(id string, headerValues []string)

SetHeader is called to set the key values for each of the data values. Must be called before Write is.

func (*NullStreamWriter) Write

func (*NullStreamWriter) Write(data []interface{}) error

Write is called for each record of data.

type OutputStreamWriter

type OutputStreamWriter interface {
	SetHeader(id string, headerValues []string)
	Write(data []interface{}) error
	Finish()
}

OutputStreamWriter is the default interface for all output writers.

func CreateStreamWriter

func CreateStreamWriter(format string, w io.Writer) OutputStreamWriter

CreateStreamWriter creates a formatted writer with the default options.

type Prompter

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

Prompter proves a user input dialog.

func NewPrompter

func NewPrompter(message string, choices []string, defaultValue string) *Prompter

NewPrompter creates a Prompter with the given message, choices and defaults.

func (*Prompter) Prompt

func (p *Prompter) Prompt() string

Prompt prompts the user and return the value. If the config parameter "y" is set we will return the default.

type SpinnerTable

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

SpinnerTable is view for a job run table with spinners.

func NewSpinnerTable

func NewSpinnerTable() *SpinnerTable

NewSpinnerTable creates a new table with Spinners.

func (*SpinnerTable) AddTask

func (s *SpinnerTable) AddTask(name string) *TaskInfo

AddTask puts a task on the display.

func (*SpinnerTable) Wait

func (s *SpinnerTable) Wait()

Wait for all the spinners to complete.

type TableAccumulator

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

TableAccumulator accumulates all data from the table.

func NewTableAccumulator

func NewTableAccumulator() *TableAccumulator

NewTableAccumulator creates a table accumulator based on input stream.

func (*TableAccumulator) Data

func (t *TableAccumulator) Data() [][]interface{}

Data returns the underlying data table as slice of slices.

func (*TableAccumulator) Finish

func (t *TableAccumulator) Finish()

Finish is called when all the data has been sent. For table accumulator it's a noop.

func (*TableAccumulator) Header

func (t *TableAccumulator) Header() []string

Header returns the header values as a string.

func (*TableAccumulator) Name

func (t *TableAccumulator) Name() string

Name returns the table name.

func (*TableAccumulator) SetHeader

func (t *TableAccumulator) SetHeader(id string, headerValues []string)

SetHeader is called to set the key values for each of the data values. Must be called before Write is.

func (*TableAccumulator) Write

func (t *TableAccumulator) Write(data []interface{}) error

Write is called for each record of data.

type TableStreamWriter

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

TableStreamWriter writer output in tabular format. It's blocking so data is only written after the table is complete.

func NewTableStreamWriter

func NewTableStreamWriter(w io.Writer) *TableStreamWriter

NewTableStreamWriter creates a table writer based on input stream.

func (*TableStreamWriter) Finish

func (t *TableStreamWriter) Finish()

Finish is called when all the data has been sent. In the case of the table we can now render all the values.

func (*TableStreamWriter) SetHeader

func (t *TableStreamWriter) SetHeader(id string, headerValues []string)

SetHeader is called to set the key values for each of the data values. Must be called before Write is.

func (*TableStreamWriter) Write

func (t *TableStreamWriter) Write(data []interface{}) error

Write is called for each record of data.

type TableView

type TableView interface {
	Name() string
	Header() []string
	Data() [][]interface{}
}

TableView is the interface the provides read access to underlying table data.

type TaskInfo

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

TaskInfo is the information associated with a task.

func (*TaskInfo) Complete

func (t *TaskInfo) Complete(err error)

Complete finishes the task.

Jump to

Keyboard shortcuts

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