utils

package
v0.23.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 17 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTemplate

func ApplyTemplate(str string, object interface{}) string

func CloseMany added in v0.17.1

func CloseMany(closers []io.Closer) error

func ColoredString

func ColoredString(str string, colorAttribute color.Attribute) string

ColoredString takes a string and a colour attribute and returns a colored string with that attribute

func ColoredStringDirect

func ColoredStringDirect(str string, colour *color.Color) string

ColoredStringDirect used for aggregating a few color attributes rather than just sending a single one

func ColoredYamlString added in v0.21.0

func ColoredYamlString(str string) string

ColoredYamlString takes an YAML formatted string and returns a colored string with colors hardcoded as: keys: cyan Booleans: magenta Numbers: yellow Strings: green

func Decolorise

func Decolorise(str string) string

Decolorise strips a string of color

func FormatBinaryBytes

func FormatBinaryBytes(b int) string

func FormatDecimalBytes

func FormatDecimalBytes(b int) string

func FormatMap added in v0.2.1

func FormatMap(padding int, m map[string]string) string

FormatMap is for displaying a map

func FormatMapItem added in v0.2.1

func FormatMapItem(padding int, k string, v interface{}) string

FormatMapItem is for displaying items in a map

func GetColorAttribute

func GetColorAttribute(key string) color.Attribute

GetColorAttribute gets the color attribute from the string

func GetGocuiAttribute

func GetGocuiAttribute(key string) gocui.Attribute

GetGocuiAttribute gets the gocui color attribute from the string

func IsValidHexValue added in v0.18.1

func IsValidHexValue(v string) bool

func Loader

func Loader() string

Loader dumps a string to be displayed as a loader

func MarshalIntoYaml added in v0.21.0

func MarshalIntoYaml(data interface{}) ([]byte, error)

MarshalIntoYaml gets any json-tagged data and marshal it into yaml saving original json structure. Useful for structs from 3rd-party libs without yaml tags.

func Max

func Max(x, y int) int

Max returns the maximum of two integers

func MultiColoredString added in v0.17.1

func MultiColoredString(str string, colorAttribute ...color.Attribute) string

MultiColoredString takes a string and an array of colour attributes and returns a colored string with those attributes

func NormalizeLinefeeds

func NormalizeLinefeeds(str string) string

NormalizeLinefeeds - Removes all Windows and Mac style line feeds

func OpensMenuStyle added in v0.20.0

func OpensMenuStyle(str string) string

Style used on menu items that open another menu

func RenderTable

func RenderTable(rows [][]string) (string, error)

RenderTable takes an array of string arrays and returns a table containing the values

func ResolvePlaceholderString

func ResolvePlaceholderString(str string, arguments map[string]string) string

ResolvePlaceholderString populates a template with values

func SafeTruncate added in v0.18.1

func SafeTruncate(str string, limit int) string

func SplitLines

func SplitLines(multilineString string) []string

SplitLines takes a multiline string and splits it on newlines currently we are also stripping \r's which may have adverse effects for windows users (but no issues have been raised yet)

func WithPadding

func WithPadding(str string, padding int) string

WithPadding pads a string as much as you want

func WithShortSha added in v0.2.1

func WithShortSha(str string) string

WithShortSha returns a command but with a shorter SHA. in the terminal we're all used to 10 character SHAs but under the hood they're actually 64 characters long. No need including all the characters when we're just displaying a command

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL