interactive

package
v2.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IsInteractive must be set to print anything with Printer functions (Print, Printf,...).
	IsInteractive = isInteractive()

	// TerminalOutput define if the
	TerminalOutput = IsInteractive
)

Functions

func Center

func Center(str string) string

func Indent

func Indent(str string, indent int) string

func InjectMockResponseToContext

func InjectMockResponseToContext(ctx context.Context, mockValues []string) context.Context

func Line

func Line(char string) string

func Print

func Print(a ...interface{}) (int, error)

func Printf

func Printf(format string, a ...interface{}) (int, error)

func Println

func Println(a ...interface{}) (int, error)

func PrintlnWithoutIndent

func PrintlnWithoutIndent(a string) (int, error)

func PromptBoolWithConfig

func PromptBoolWithConfig(config *PromptBoolConfig) (bool, error)

func PromptPasswordWithConfig

func PromptPasswordWithConfig(config *PromptPasswordConfig) (string, error)

func PromptStringWithConfig

func PromptStringWithConfig(config *PromptStringConfig) (string, error)

func Readline

func Readline(config *ReadlineConfig) (string, error)

func RemoveIndent

func RemoveIndent(str string) string

func SetOutputWriter

func SetOutputWriter(w io.Writer)

SetOutputWriter set the output writer that will be used by both Printer functions (Print, Printf,...) and readline prompter. This should be called once from the bootstrap function.

Types

type EOFError

type EOFError struct{}

func (*EOFError) Error

func (e *EOFError) Error() string

type InterruptError

type InterruptError struct{}

func (*InterruptError) Error

func (e *InterruptError) Error() string

func (*InterruptError) MarshalHuman

func (e *InterruptError) MarshalHuman() string

type ListPrompt added in v2.16.0

type ListPrompt struct {
	// Prompt that will be printed when showing the list
	Prompt  string
	Choices []string
	// DefaultIndex is the element that will be selected when starting prompt
	DefaultIndex int
	// contains filtered or unexported fields
}

func (*ListPrompt) Execute added in v2.16.0

func (m *ListPrompt) Execute(ctx context.Context) (int, error)

Execute start the prompt and return the selected index

func (*ListPrompt) Init added in v2.16.0

func (m *ListPrompt) Init() tea.Cmd

func (*ListPrompt) Update added in v2.16.0

func (m *ListPrompt) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*ListPrompt) View added in v2.16.0

func (m *ListPrompt) View() string

type PromptBoolConfig

type PromptBoolConfig struct {
	Ctx          context.Context
	Prompt       string
	DefaultValue bool
}

type PromptPasswordConfig

type PromptPasswordConfig struct {
	Ctx    context.Context
	Prompt string
}

type PromptStringConfig

type PromptStringConfig struct {
	Ctx             context.Context
	Prompt          string
	DefaultValue    string
	DefaultValueDoc string
	ValidateFunc    ValidateFunc
}

type ReadlineConfig

type ReadlineConfig struct {
	Ctx          context.Context
	Prompt       string
	PromptFunc   func(string) string
	Password     bool
	ValidateFunc ValidateFunc
	DefaultValue string
}

type ReadlineHandler

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

func (*ReadlineHandler) SetPrompt

func (h *ReadlineHandler) SetPrompt(prompt string)

type ValidateFunc

type ValidateFunc func(string) error

func ValidateOrganizationID

func ValidateOrganizationID() ValidateFunc

Jump to

Keyboard shortcuts

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