Documentation ¶
Index ¶
- Constants
- Variables
- func CenterText(str string, width int) string
- func DoesNotInclude(strs []string, val string) bool
- func ExecuteCommand(cmd *exec.Cmd) string
- func ExpandHomeDir(path string) (string, error)
- func FindMatch(pattern string, data string) [][]string
- func HelpFromInterface(item interface{}) string
- func HighlightableHelper(view *tview.TextView, input string, idx, offset int) string
- func Home() (string, error)
- func Includes(strs []string, val string) bool
- func Init(openFileUtil string)
- func MapToStrs(aMap map[string]interface{}) map[string]string
- func NameFromEmail(email string) string
- func NamesFromEmails(emails []string) []string
- func OpenFile(path string)
- func ParseJson(obj interface{}, text io.Reader) error
- func ReadFileBytes(filePath string) ([]byte, error)
- func RowPadding(offset int, max int) string
- func StripColorTags(input string) string
- func ToInts(slice []interface{}) []int
- func ToStrs(slice []interface{}) []string
Constants ¶
const ( SimpleDateFormat = "Jan 2" SimpleTimeFormat = "15:04 MST" MinimumTimeFormat = "15:04" FullDateFormat = "Monday, Jan 2" FriendlyDateFormat = "Mon, Jan 2" FriendlyDateTimeFormat = "Mon, Jan 2, 15:04" TimestampFormat = "2006-01-02T15:04:05-0700" )
Variables ¶
var OpenFileUtil = "open"
OpenFileUtil defines the system utility to use to open files
Functions ¶
func CenterText ¶ added in v0.20.0
CenterText takes a string and a width and pads the left and right of the string with empty spaces to ensure that the string is in the middle of the returned value
Example:
x := CenterText("cat", 11) > " cat "
func DoesNotInclude ¶ added in v0.20.0
DoesNotInclude takes a slice of strings and a target string and returns TRUE if the slice does not include the target, FALSE if it does
Example:
x := DoesNotInclude([]string{"cat", "dog", "rat"}, "dog") > false x := DoesNotInclude([]string{"cat", "dog", "rat"}, "pig") > true
func ExecuteCommand ¶ added in v0.20.0
ExecuteCommand executes an external command on the local machine as the current user
func ExpandHomeDir ¶
ExpandHomeDir expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.
func FindMatch ¶ added in v0.20.0
FindMatch takes a regex pattern and a string of data and returns back all the matches in that string
func HelpFromInterface ¶ added in v0.11.0
func HelpFromInterface(item interface{}) string
func HighlightableHelper ¶ added in v0.20.0
HighlightableHelper pads the given text with blank spaces to the width of the view containing it. This is helpful for extending row highlighting across the entire width of the view
func Home ¶
Home returns the home directory for the executing user. An error is returned if a home directory cannot be detected.
func Includes ¶ added in v0.21.0
Includes takes a slice of strings and a target string and returns TRUE if the slice includes the target, FALSE if it does not
Example:
x := Includes([]string{"cat", "dog", "rat"}, "dog") > true x := Includes([]string{"cat", "dog", "rat"}, "pig") > false
func Init ¶ added in v0.20.0
func Init(openFileUtil string)
Init initializes global settings in the wtf package
func NameFromEmail ¶ added in v0.20.0
NameFromEmail takes an email address and returns the part that comes before the @ symbol
Example:
NameFromEmail("test_user@example.com") > "Test_user"
func NamesFromEmails ¶ added in v0.20.0
NamesFromEmails takes a slice of email addresses and returns a slice of the parts that come before the @ symbol
Example:
NamesFromEmail("test_user@example.com", "other_user@example.com") > []string{"Test_user", "Other_user"}
func OpenFile ¶ added in v0.20.0
func OpenFile(path string)
OpenFile opens the file defined in `path` via the operating system
func ReadFileBytes ¶ added in v0.20.0
ReadFileBytes reads the contents of a file and returns those contents as a slice of bytes
func RowPadding ¶ added in v0.20.0
RowPadding returns a padding for a row to make it the full width of the containing widget. Useful for ensurig row highlighting spans the full width (I suspect tcell has a better way to do this, but I haven't yet found it)
func StripColorTags ¶ added in v0.11.0
StripColorTags removes tcell color tags from a given string
Types ¶
This section is empty.