Documentation ¶
Index ¶
- Constants
- Variables
- func AddColorFunctions(addCallback func(string, any))
- func AddColorFunctionsForCobra()
- func BeautifyCobraUsageAndHelp(rootCmd *cobra.Command)
- func CheckCommandArgsAndMayPrintHelp(cmd *cobra.Command, args []string, minArgs int) (shouldContinue bool, err error)
- func PrintTable(rows [][]string, header bool)
- func Prompt(prompt string) string
- func PromptForAnswerOrAbortError(answer string, format string, a ...any) error
- func PromptForConfirmAnswer(answer string, format string, a ...any) (bool, string)
- func PromptForConfirmNo(format string, a ...any) (bool, string)
- func PromptForConfirmOrAbortError(format string, a ...any) error
- func PromptForConfirmYes(format string, a ...any) (bool, string)
- func PromptForPassword(format string, a ...any) string
- func SuggestionFromFormat(format string, a ...any) (errorx.Property, string)
- func SuggestionFromString(str string) (errorx.Property, string)
- func SuggestionFromTemplate(templateStr string, data any) (errorx.Property, string)
- type SSHConnectionProps
Constants ¶
const (
ASCIIArtWarning = `` /* 623-byte string literal not displayed */
)
pre-defined ascii art strings
Variables ¶
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) )
Functions ¶
func AddColorFunctions ¶
AddColorFunctions invokes callback for each colorize functions.
func AddColorFunctionsForCobra ¶
func AddColorFunctionsForCobra()
AddColorFunctionsForCobra adds colorize functions to cobra, so that they can be used in usage or help.
func BeautifyCobraUsageAndHelp ¶
BeautifyCobraUsageAndHelp beautifies cobra usages and help.
func CheckCommandArgsAndMayPrintHelp ¶
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 PrintTable ¶
PrintTable accepts a matrix of strings and print them as ASCII table to terminal
func PromptForAnswerOrAbortError ¶
PromptForAnswerOrAbortError accepts string from console by user, generates AbortError if user does not input the pre-defined answer.
func PromptForConfirmAnswer ¶
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 ¶
PromptForConfirmNo accepts yes / no from console by user, default to Yes and only return true if the user input is No
func PromptForConfirmOrAbortError ¶
PromptForConfirmOrAbortError accepts yes / no from console by user, generates AbortError if user does not input yes.
func PromptForConfirmYes ¶
PromptForConfirmYes accepts yes / no from console by user, default to No and only return true if the user input is Yes
func PromptForPassword ¶
PromptForPassword reads a password input from console
func SuggestionFromFormat ¶
SuggestionFromFormat creates a suggestion from a format. Usage: SomeErrorX.WithProperty(SuggestionFromFormat(..))
func SuggestionFromString ¶
SuggestionFromString creates a suggestion from string. Usage: SomeErrorX.WithProperty(SuggestionFromString(..))
Types ¶
type SSHConnectionProps ¶
type SSHConnectionProps struct { Password string IdentityFile string IdentityFilePassphrase string }
SSHConnectionProps is SSHConnectionProps
func ReadIdentityFileOrPassword ¶
func ReadIdentityFileOrPassword(identityFilePath string, usePass bool) (*SSHConnectionProps, error)
ReadIdentityFileOrPassword is ReadIdentityFileOrPassword