{"modulePath":"github.com/randomtask1155/cli","version":"v6.22.2+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ui\n\npackage ui will provide hooks into STDOUT, STDERR and STDIN. It will also handle translation as necessary.\n\nThis package is explicitly designed for the CF CLI and is \\*not\\* to be used by any package outside of the commands package.\n\n## Functions\n\n```go\nfunc GetTranslationFunc(config Config) (i18n.TranslateFunc, error)\n```\n\n## Types\n\n```go\ntype Config interface {\n\t// ColorEnabled enables or disabled color\n\tColorEnabled() configv3.ColorSetting\n\n\t// Locale is the language to translate the output to\n\tLocale() string\n}\n```\nConfig is the UI configuration\n\n```go\ntype TranslatableError interface {\n\t// Returns back the untranslated error string\n\tError() string\n\tTranslate(func(string, ...interface{}) string) string\n}\n```\nTranslatableError it wraps the error interface adding a way to set the translation function on the error\n\n```go\ntype UI struct {\n\t// In is the input buffer\n\tIn io.Reader\n\n\t// Out is the output buffer\n\tOut io.Writer\n\n\t// Err is the error buffer\n\tErr io.Writer\n\t// contains filtered or unexported fields\n}\n```\nUI is interface to interact with the user\n\n```go\nfunc NewTestUI(in io.Reader, out io.Writer, err io.Writer) *UI\n```\nNewTestUI will return a UI object where Out, In, and Err are customizable, and colors are disabled\n\n```go\nfunc NewUI(c Config) (*UI, error)\n```\nNewUI will return a UI object where Out is set to STDOUT, In is set to STDIN, and Err is set to STDERR\n\n```go\nfunc (ui *UI) DisplayBoolPrompt(prompt string, defaultResponse bool) (bool, error)\n```\nDisplayBoolPrompt outputs the prompt and waits for user input. It only allows for a boolean response. A default boolean response can be set with defaultResponse.\n\n```go\nfunc (ui *UI) DisplayError(err TranslatableError)\n```\nDisplayError outputs the error to UI.Err and outputs a red translated \"FAILED\" to UI.Out.\n\n```go\nfunc (ui *UI) DisplayErrorMessage(err string, keys ...map[string]interface{})\n```\nDisplayErrorMessage combines the err template with the key maps and then outputs it to the UI.Err file. It will then output a red translated \"FAILED\" to UI.Out. Prior to outputting the err, it is run through an internationalization function to translate it to a pre-configured language.\n\n```go\nfunc (ui *UI) DisplayHeaderFlavorText(formattedString string, keys ...map[string]interface{})\n```\nDisplayHeaderFlavorText outputs the translated text, with cyan color keys, to UI.Out.\n\n```go\nfunc (ui *UI) DisplayHelpHeader(text string)\n```\nDisplayHelpHeader translates and then bolds the help header. Sends output to UI.Out.\n\n```go\nfunc (ui *UI) DisplayNewline()\n```\nDisplayNewline outputs a newline to UI.Out.\n\n```go\nfunc (ui *UI) DisplayOK()\n```\nDisplayOK outputs a green translated \"OK\" message to UI.Out.\n\n```go\nfunc (ui *UI) DisplayPair(attribute string, formattedString string, keys ...map[string]interface{})\n```\nDisplayPair outputs the \"attribute: formattedString\" pair to UI.Out. keys are applied to the translation of formattedString, while attribute is translated directly.\n\n```go\nfunc (ui *UI) DisplayTable(prefix string, table [][]string)\n```\nDisplayTable presents a two dimensional array of strings as a table to UI.Out\n\n```go\nfunc (ui *UI) DisplayText(formattedString string, keys ...map[string]interface{})\n```\nDisplayText combines the formattedString template with the key maps and then outputs it to the UI.Out file. Prior to outputting the formattedString, it is run through an internationalization function to translate it to a pre-configured language. Only the first map in keys is used.\n\n```go\nfunc (ui *UI) DisplayTextWithKeyTranslations(formattedString string, keysToTranslate []string, keys ...map[string]interface{})\n```\nDisplayTextWithKeyTranslations translates the keys listed in keysToTranslate, and then passes these values to DisplayText. Only the first map in keys is used.\n\n```go\nfunc (ui *UI) DisplayWarning(formattedString string, keys ...map[string]interface{})\n```\nDisplayWarning applies translation to formattedString and displays the translated warning to UI.Err.\n\n```go\nfunc (ui *UI) DisplayWarnings(warnings []string)\n```\nDisplayWarnings translates and displays the warnings.\n\n","path":"github.com/randomtask1155/cli/utils/ui","name":"ui","synopsis":"package ui will provide hooks into STDOUT, STDERR and STDIN.","isRedistributable":true}
