ui

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Overview

Package ui contains some generic UI k6 components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field added in v0.16.0

type Field interface {
	GetKey() string                        // Key for the data map.
	GetLabel() string                      // Label to print as the prompt.
	GetLabelExtra() string                 // Extra info for the label, eg. defaults.
	GetContents(io.Reader) (string, error) // Read the field contents from the supplied reader

	// Sanitize user input and return the field's native type.
	Clean(s string) (string, error)
}

A Field in a form.

type Form added in v0.16.0

type Form struct {
	Banner string
	Fields []Field
}

A Form used to handle user interactions.

func (Form) Run added in v0.16.0

func (f Form) Run(r io.Reader, w io.Writer) (map[string]string, error)

Run executes the form against the specified input and output.

type PasswordField added in v0.23.0

type PasswordField struct {
	Key   string
	Label string
	Min   int
}

PasswordField masks password input

func (PasswordField) Clean added in v0.23.0

func (f PasswordField) Clean(s string) (string, error)

Clean just checks if the minimum length is exceeded, it doesn't trim the string!

func (PasswordField) GetContents added in v0.23.0

func (f PasswordField) GetContents(r io.Reader) (string, error)

GetContents simply reads a string in cleartext from the supplied reader

func (PasswordField) GetKey added in v0.23.0

func (f PasswordField) GetKey() string

GetKey returns the field's key

func (PasswordField) GetLabel added in v0.23.0

func (f PasswordField) GetLabel() string

GetLabel returns the field's label

func (PasswordField) GetLabelExtra added in v0.23.0

func (f PasswordField) GetLabelExtra() string

GetLabelExtra doesn't return anything so we don't expose the current password

type StringField added in v0.16.0

type StringField struct {
	Key     string
	Label   string
	Default string

	// Length constraints.
	Min, Max int
}

StringField is just a simple field for reading cleartext strings

func (StringField) Clean added in v0.16.0

func (f StringField) Clean(s string) (string, error)

Clean trims the spaces in the string and checks for min and max length

func (StringField) GetContents added in v0.23.0

func (f StringField) GetContents(r io.Reader) (string, error)

GetContents simply reads a string in cleartext from the supplied reader It's compllicated and doesn't use t he bufio utils because we can't read ahead of the newline and consume more of the stdin, because we'll mess up the next form field

func (StringField) GetKey added in v0.16.0

func (f StringField) GetKey() string

GetKey returns the field's key

func (StringField) GetLabel added in v0.16.0

func (f StringField) GetLabel() string

GetLabel returns the field's label

func (StringField) GetLabelExtra added in v0.16.0

func (f StringField) GetLabelExtra() string

GetLabelExtra returns the field's default value

Directories

Path Synopsis
Package console implements the command-line UI for k6.
Package console implements the command-line UI for k6.
Package pb implements a progressbar component for CLI user interfaces
Package pb implements a progressbar component for CLI user interfaces

Jump to

Keyboard shortcuts

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