tui

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 18 Imported by: 11

Documentation

Index

Constants

View Source
const (
	ASCIIArtWarning = `` /* 623-byte string literal not displayed */

)

pre-defined ascii art strings

Variables

View Source
var (
	// ColorErrorMsg is the ansi color formatter for error messages
	ColorErrorMsg = color.New(color.FgHiRed)
	// ColorSuccessMsg is the ansi color formatter for success messages
	ColorSuccessMsg = color.New(color.FgHiGreen)
	// ColorWarningMsg is the ansi color formatter for warning messages
	ColorWarningMsg = color.New(color.FgHiYellow)
	// ColorCommand is the ansi color formatter for commands
	ColorCommand = color.New(color.FgHiBlue, color.Bold)
	// ColorKeyword is the ansi color formatter for cluster name
	ColorKeyword = color.New(color.FgHiBlue, color.Bold)
)
View Source
var (
	// ErrIdentityFileReadFailed is ErrIdentityFileReadFailed
	ErrIdentityFileReadFailed = errNS.NewType("id_read_failed", utils.ErrTraitPreCheck)
)

Functions

func AddColorFunctions added in v1.6.0

func AddColorFunctions(addCallback func(string, interface{}))

AddColorFunctions invokes callback for each colorize functions.

func AddColorFunctionsForCobra added in v1.6.0

func AddColorFunctionsForCobra()

AddColorFunctionsForCobra adds colorize functions to cobra, so that they can be used in usage or help.

func BeautifyCobraUsageAndHelp added in v1.6.0

func BeautifyCobraUsageAndHelp(rootCmd *cobra.Command)

BeautifyCobraUsageAndHelp beautifies cobra usages and help.

func CheckCommandArgsAndMayPrintHelp added in v1.6.0

func CheckCommandArgsAndMayPrintHelp(cmd *cobra.Command, args []string, minArgs int) (shouldContinue bool, err error)

CheckCommandArgsAndMayPrintHelp checks whether user passes enough number of arguments. If insufficient number of arguments are passed, an error with proper suggestion will be raised. When no argument is passed, command help will be printed and no error will be raised.

func OsArch added in v1.6.0

func OsArch(os, arch string) string

OsArch builds an "os/arch" string from input, it converts some similar strings to different words to avoid misreading when displaying in terminal

func OsArgs added in v1.6.0

func OsArgs() string

OsArgs return the whole command line that user inputs, e.g. tiup deploy --xxx, or tiup cluster deploy --xxx

func OsArgs0 added in v1.6.0

func OsArgs0() string

OsArgs0 return the command name that user inputs, e.g. tiup, or tiup cluster.

func PrintTable

func PrintTable(rows [][]string, header bool)

PrintTable accepts a matrix of strings and print them as ASCII table to terminal

func Prompt added in v1.6.0

func Prompt(prompt string) string

Prompt accepts input from console by user

func PromptForAnswerOrAbortError added in v1.8.0

func PromptForAnswerOrAbortError(answer string, format string, a ...interface{}) error

PromptForAnswerOrAbortError accepts string from console by user, generates AbortError if user does not input the pre-defined answer.

func PromptForConfirmAnswer added in v1.8.0

func PromptForConfirmAnswer(answer string, format string, a ...interface{}) (bool, string)

PromptForConfirmAnswer accepts string from console by user, default to empty and only return true if the user input is exactly the same as pre-defined answer.

func PromptForConfirmNo added in v1.6.0

func PromptForConfirmNo(format string, a ...interface{}) (bool, string)

PromptForConfirmNo accepts yes / no from console by user, default to Yes and only return true if the user input is No

func PromptForConfirmOrAbortError added in v1.6.0

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

PromptForConfirmOrAbortError accepts yes / no from console by user, generates AbortError if user does not input yes.

func PromptForConfirmYes added in v1.6.0

func PromptForConfirmYes(format string, a ...interface{}) (bool, string)

PromptForConfirmYes accepts yes / no from console by user, default to No and only return true if the user input is Yes

func PromptForPassword added in v1.6.0

func PromptForPassword(format string, a ...interface{}) string

PromptForPassword reads a password input from console

func RegisterArg0 added in v1.6.0

func RegisterArg0(s string)

RegisterArg0 register arg0

func SuggestionFromFormat added in v1.6.0

func SuggestionFromFormat(format string, a ...interface{}) (errorx.Property, string)

SuggestionFromFormat creates a suggestion from a format. Usage: SomeErrorX.WithProperty(SuggestionFromFormat(..))

func SuggestionFromString added in v1.6.0

func SuggestionFromString(str string) (errorx.Property, string)

SuggestionFromString creates a suggestion from string. Usage: SomeErrorX.WithProperty(SuggestionFromString(..))

func SuggestionFromTemplate added in v1.6.0

func SuggestionFromTemplate(templateStr string, data interface{}) (errorx.Property, string)

SuggestionFromTemplate creates a suggestion from go template. Colorize function and some other utilities are available. Usage: SomeErrorX.WithProperty(SuggestionFromTemplate(..))

Types

type SSHConnectionProps added in v1.6.0

type SSHConnectionProps struct {
	Password               string
	IdentityFile           string
	IdentityFilePassphrase string
}

SSHConnectionProps is SSHConnectionProps

func ReadIdentityFileOrPassword added in v1.6.0

func ReadIdentityFileOrPassword(identityFilePath string, usePass bool) (*SSHConnectionProps, error)

ReadIdentityFileOrPassword is ReadIdentityFileOrPassword

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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