Documentation ¶
Index ¶
- Variables
- func BeautifyCobraUsageAndHelp(rootCmd *cobra.Command)
- func CheckCommandArgsAndMayPrintHelp(cmd *cobra.Command, args []string, minArgs int) (shouldContinue bool, err error)
- func OsArch(os, arch string) string
- func OsArgs() string
- func OsArgs0() string
- func PrintTable(rows [][]string, header bool)
- func Prompt(prompt string) string
- func PromptForConfirm(format string, a ...interface{}) bool
- func PromptForConfirmOrAbortError(format string, a ...interface{}) error
- func PromptForPassword(format string, a ...interface{}) string
- func SuggestionFromFormat(format string, a ...interface{}) (errorx.Property, string)
- func SuggestionFromString(str string) (errorx.Property, string)
- func SuggestionFromTemplate(templateStr string, data interface{}) (errorx.Property, string)
- type SSHConnectionProps
Constants ¶
This section is empty.
Variables ¶
var ( // ErrIdentityFileReadFiled is ErrIdentityFileReadFiled ErrIdentityFileReadFiled = errNS.NewType("id_read_failed", errutil.ErrTraitPreCheck) )
Functions ¶
func BeautifyCobraUsageAndHelp ¶ added in v0.5.0
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 OsArch ¶ added in v0.6.1
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 ¶
func OsArgs() string
OsArgs return the whole command line that user inputs, e.g. tiops deploy --xxx, or tiup cluster deploy --xxx
func OsArgs0 ¶
func OsArgs0() string
OsArgs0 return the command name that user inputs, e.g. tiops, or tiup cluster.
func PrintTable ¶
PrintTable accepts a matrix of strings and print them as ASCII table to terminal
func PromptForConfirm ¶
PromptForConfirm accepts yes / no from console by user
func PromptForConfirmOrAbortError ¶
PromptForConfirmOrAbortError accepts yes / no from console by user, generates AbortError if user does not input 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(..))
func SuggestionFromTemplate ¶
SuggestionFromTemplate creates a suggestion from go template. Colorize function and some other utilities are available. Usage: SomeErrorX.WithProperty(SuggestionFromTemplate(..))
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