Documentation ¶
Index ¶
- func AsJson(i interface{}) string
- func Clamp(x int, min int, max int) int
- func Decolorise(str string) string
- func EscapeSpecialChars(str string) string
- func FilePath(skip int) string
- func FindNamedMatches(regex *regexp.Regexp, str string) map[string]string
- func FindStringSubmatch(str string, regexpStr string) (bool, []string)
- func ForEachLineInFile(path string, f func(string, int)) error
- func FuzzySearch(needle string, haystack []string) []string
- func GetCurrentRepoName() string
- func GetProjectRoot() string
- func IsValidHexValue(v string) bool
- func Limit(values []string, limit int) []string
- func LimitStr(value string, limit int) string
- func Loader() string
- func Max(x, y int) int
- func Min(x, y int) int
- func ModuloWithWrap(n, max int) int
- func MoveElement[T any](slice []T, from int, to int) []T
- func MoveTodoDown(fileName string, sha string, action todo.TodoCommand) error
- func MoveTodoUp(fileName string, sha string, action todo.TodoCommand) error
- func MuiltiGroupBy[T any, K comparable](slice []T, f func(T) []K) map[K][]T
- func MustConvertToInt(s string) int
- func NewDummyCommon() *common.Common
- func NewDummyCommonWithUserConfig(userConfig *config.UserConfig) *common.Common
- func NewDummyLog() *logrus.Entry
- func NextIndex(numbers []int, currentNumber int) int
- func NextIntInCycle(sl []int, current int) int
- func NormalizeLinefeeds(str string) string
- func PrevIndex(numbers []int, currentNumber int) int
- func PrevIntInCycle(sl []int, current int) int
- func ReadRebaseTodoFile(fileName string) ([]todo.Todo, error)
- func RenderDisplayStrings(displayStringsArr [][]string) string
- func ResolvePlaceholderString(str string, arguments map[string]string) string
- func ResolveTemplate(templateStr string, object interface{}, funcs template.FuncMap) (string, error)
- func Safe(f func())
- func SafeTruncate(str string, limit int) string
- func SafeWithError(f func() error) error
- func SetCustomColors(customColors map[string]string) map[string]style.TextStyle
- func ShortSha(sha string) string
- func SplitLines(multilineString string) []string
- func SplitNul(str string) []string
- func StackTrace() string
- func StringArraysOverlap(strArrA []string, strArrB []string) bool
- func TruncateWithEllipsis(str string, limit int) string
- func UnixToDate(timestamp int64, timeFormat string) string
- func UnixToTimeAgo(timestamp int64) string
- func WithPadding(str string, padding int) string
- func WrapError(err error) error
- func WriteRebaseTodoFile(fileName string, todos []todo.Todo) error
- type OnceWriter
- type StringStack
- type ThreadSafeMap
- func (m *ThreadSafeMap[K, V]) Clear()
- func (m *ThreadSafeMap[K, V]) Delete(key K)
- func (m *ThreadSafeMap[K, V]) Get(key K) (V, bool)
- func (m *ThreadSafeMap[K, V]) Has(key K) bool
- func (m *ThreadSafeMap[K, V]) IsEmpty() bool
- func (m *ThreadSafeMap[K, V]) Keys() []K
- func (m *ThreadSafeMap[K, V]) Len() int
- func (m *ThreadSafeMap[K, V]) Set(key K, value V)
- func (m *ThreadSafeMap[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeSpecialChars ¶
EscapeSpecialChars - Replaces all special chars like \n with \\n
func FilePath ¶
returns the path of the file that calls the function. 'skip' is the number of stack frames to skip.
func FuzzySearch ¶
func GetCurrentRepoName ¶
func GetCurrentRepoName() string
GetCurrentRepoName gets the repo's base name
func GetProjectRoot ¶
func GetProjectRoot() string
GetProjectRoot returns the path to the root of the project. Only to be used in testing contexts, as with binaries it's unlikely this path will exist on the machine
func IsValidHexValue ¶
func ModuloWithWrap ¶
used to keep a number n between 0 and max, allowing for wraparounds
func MoveElement ¶
Returns a new slice with the element at index 'from' moved to index 'to'. Does not mutate original slice.
func MoveTodoDown ¶
func MoveTodoDown(fileName string, sha string, action todo.TodoCommand) error
func MoveTodoUp ¶
func MoveTodoUp(fileName string, sha string, action todo.TodoCommand) error
func MuiltiGroupBy ¶
func MuiltiGroupBy[T any, K comparable](slice []T, f func(T) []K) map[K][]T
Similar to a regular GroupBy, except that each item can be grouped under multiple keys, so the callback returns a slice of keys instead of just one key.
func MustConvertToInt ¶
func NewDummyCommon ¶
func NewDummyCommonWithUserConfig ¶
func NewDummyCommonWithUserConfig(userConfig *config.UserConfig) *common.Common
func NextIntInCycle ¶
NextIntInCycle returns the next int in a slice, returning to the first index if we've reached the end
func NormalizeLinefeeds ¶
NormalizeLinefeeds - Removes all Windows and Mac style line feeds
func PrevIndex ¶
PrevIndex returns the index that comes before the given number, cycling if we reach the end
func PrevIntInCycle ¶
PrevIntInCycle returns the prev int in a slice, returning to the first index if we've reached the end
func RenderDisplayStrings ¶
func ResolvePlaceholderString ¶
ResolvePlaceholderString populates a template with values
func ResolveTemplate ¶
func Safe ¶
func Safe(f func())
Safe will close tcell if a panic occurs so that we don't end up in a malformed terminal state
func SafeTruncate ¶
func SafeWithError ¶
func SetCustomColors ¶
func SplitLines ¶
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 StackTrace ¶
func StackTrace() string
func StringArraysOverlap ¶
func TruncateWithEllipsis ¶
TruncateWithEllipsis returns a string, truncated to a certain length, with an ellipsis
func UnixToDate ¶
func UnixToTimeAgo ¶
func WithPadding ¶
WithPadding pads a string as much as you want
Types ¶
type OnceWriter ¶
type OnceWriter struct {
// contains filtered or unexported fields
}
func NewOnceWriter ¶
func NewOnceWriter(writer io.Writer, f func()) *OnceWriter
type StringStack ¶
type StringStack struct {
// contains filtered or unexported fields
}
func (*StringStack) Clear ¶
func (self *StringStack) Clear()
func (*StringStack) IsEmpty ¶
func (self *StringStack) IsEmpty() bool
func (*StringStack) Pop ¶
func (self *StringStack) Pop() string
func (*StringStack) Push ¶
func (self *StringStack) Push(s string)
type ThreadSafeMap ¶
type ThreadSafeMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewThreadSafeMap ¶
func NewThreadSafeMap[K comparable, V any]() *ThreadSafeMap[K, V]
func (*ThreadSafeMap[K, V]) Clear ¶
func (m *ThreadSafeMap[K, V]) Clear()
func (*ThreadSafeMap[K, V]) Delete ¶
func (m *ThreadSafeMap[K, V]) Delete(key K)
func (*ThreadSafeMap[K, V]) Get ¶
func (m *ThreadSafeMap[K, V]) Get(key K) (V, bool)
func (*ThreadSafeMap[K, V]) Has ¶
func (m *ThreadSafeMap[K, V]) Has(key K) bool
func (*ThreadSafeMap[K, V]) IsEmpty ¶
func (m *ThreadSafeMap[K, V]) IsEmpty() bool
func (*ThreadSafeMap[K, V]) Keys ¶
func (m *ThreadSafeMap[K, V]) Keys() []K
func (*ThreadSafeMap[K, V]) Len ¶
func (m *ThreadSafeMap[K, V]) Len() int
func (*ThreadSafeMap[K, V]) Set ¶
func (m *ThreadSafeMap[K, V]) Set(key K, value V)
func (*ThreadSafeMap[K, V]) Values ¶
func (m *ThreadSafeMap[K, V]) Values() []V