Documentation
¶
Index ¶
- func Argify(data string) (string, []string)
- func BestMatch(pattern string, searchList []string) int
- func ClearLine(conn io.Writer)
- func Colorize(color Color, text string) string
- func Compare(str1, str2 string) bool
- func FindAndCallMethod(object interface{}, name string, a ...interface{}) bool
- func FindMethod(object interface{}, name string) (reflect.Value, bool)
- func FormatName(name string) string
- func GetRawUserInput(conn io.ReadWriter, prompt string, cm ColorMode) string
- func GetRawUserInputP(conn io.ReadWriter, prompter Prompter, cm ColorMode) string
- func GetRawUserInputSuffix(conn io.ReadWriter, prompt string, suffix string, cm ColorMode) string
- func GetRawUserInputSuffixP(conn io.ReadWriter, prompter Prompter, suffix string, cm ColorMode) string
- func GetUserInput(conn io.ReadWriter, prompt string, cm ColorMode) string
- func GetUserInputP(conn io.ReadWriter, prompter Prompter, cm ColorMode) string
- func HandleError(err error)
- func MonitorChannel()
- func NaturalLessThan(str1, str2 string) bool
- func PanicIfError(err error)
- func Random(low, high int) int
- func Simplify(str string) string
- func TrimEmptyRows(str string) string
- func TrimLowerRows(rows []string) []string
- func TrimUpperRows(rows []string) []string
- func ValidateName(name string) error
- func Write(conn io.Writer, text string, cm ColorMode) (int, error)
- func WriteLine(conn io.Writer, line string, cm ColorMode) (int, error)
- type Color
- type ColorMode
- type Menu
- func (self *Menu) AddAction(key string, text string)
- func (self *Menu) AddActionData(key int, text string, data bson.ObjectId)
- func (self *Menu) Exec(conn io.ReadWriter, cm ColorMode) (string, bson.ObjectId)
- func (self *Menu) GetData(choice string) bson.ObjectId
- func (self *Menu) GetPrompt() string
- func (self *Menu) HasAction(key string) bool
- func (self *Menu) Print(conn io.Writer, cm ColorMode)
- type Prompter
- type SortableStrings
- type Throttler
- type WatchableReadWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BestMatch ¶
BestMatch searches the given list for the given pattern, the index of the longest match that starts with the given pattern is returned. Returns -1 if no match was found, -2 if the result is ambiguous. The search is case insensitive
func ClearLine ¶
ClearLine sends the VT100 code for erasing the line followed by a carriage return to move the cursor back to the beginning of the line
func FindAndCallMethod ¶
func FindMethod ¶
FindMethod uses reflection to find an exported method with the given name on the given object. The reflect.Value is the value of the method that was found, such that Call be be invoked on it directly. The matching is case-inensitive. In order to be able to find methods that operate on the object pointer type, a pointer to an instance of an object should be given, rather than the object itself
func FormatName ¶
func GetRawUserInput ¶
func GetRawUserInput(conn io.ReadWriter, prompt string, cm ColorMode) string
func GetRawUserInputP ¶
func GetRawUserInputP(conn io.ReadWriter, prompter Prompter, cm ColorMode) string
func GetRawUserInputSuffix ¶
func GetRawUserInputSuffixP ¶
func GetUserInput ¶
func GetUserInput(conn io.ReadWriter, prompt string, cm ColorMode) string
func GetUserInputP ¶
func GetUserInputP(conn io.ReadWriter, prompter Prompter, cm ColorMode) string
func HandleError ¶
func HandleError(err error)
func MonitorChannel ¶
func MonitorChannel()
func NaturalLessThan ¶
func PanicIfError ¶
func PanicIfError(err error)
func TrimEmptyRows ¶
func TrimLowerRows ¶
func TrimUpperRows ¶
func ValidateName ¶
Types ¶
type Color ¶
type Color string
const ( ColorRed Color = "@0" ColorGreen Color = "@1" ColorYellow Color = "@2" ColorBlue Color = "@3" ColorMagenta Color = "@4" ColorCyan Color = "@5" ColorWhite Color = "@6" ColorDarkRed Color = "#0" ColorDarkGreen Color = "#1" ColorDarkYellow Color = "#2" ColorDarkBlue Color = "#3" ColorDarkMagenta Color = "#4" ColorDarkCyan Color = "#5" ColorBlack Color = "#6" ColorGray Color = "@@" ColorNormal Color = "##" )
type Menu ¶
type Menu struct {
// contains filtered or unexported fields
}
func (*Menu) AddActionData ¶
type Prompter ¶
type Prompter interface {
GetPrompt() string
}
func SimplePrompter ¶
SimpleRompter returns a Prompter that always returns the given string as its prompt
type SortableStrings ¶
type SortableStrings []string
SortableStrings implements the sort.Interface for a []string. It uses "natural" sort order rather than asciibetical sort order.
func (SortableStrings) Len ¶
func (s SortableStrings) Len() int
func (SortableStrings) Less ¶
func (s SortableStrings) Less(i, j int) bool
func (SortableStrings) Swap ¶
func (s SortableStrings) Swap(i, j int)
type Throttler ¶
type Throttler struct {
// contains filtered or unexported fields
}
Throttler is a simple utility class that allows events to occur on a deterministic recurring basis. Every call to Sync() will block until the duration of the Throttler's interval has passed since the last call to Sync()
func NewThrottler ¶
type WatchableReadWriter ¶
type WatchableReadWriter struct {
// contains filtered or unexported fields
}
func NewWatchableReadWriter ¶
func NewWatchableReadWriter(rw io.ReadWriter) *WatchableReadWriter
func (*WatchableReadWriter) AddWatcher ¶
func (w *WatchableReadWriter) AddWatcher(rw io.ReadWriter)
func (*WatchableReadWriter) RemoveWatcher ¶
func (w *WatchableReadWriter) RemoveWatcher(rw io.ReadWriter)