utils

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteToHumanReadableFormat

func ByteToHumanReadableFormat(b int) string

func CommonElementsInStringSlice

func CommonElementsInStringSlice(s1 []string, s2 []string) (arr []string)

CommonElementsInStringSlice takes 2 Slices of Strings and returns a Third Slice that is the common elements between the first 2 Slices.

func DisplayURL

func DisplayURL(urlStr string) string

func Editor

func Editor(opts EditorOptions) string

func FmtDuration

func FmtDuration(d time.Duration) string

func Humanize

func Humanize(s string) string

func Indent

func Indent(s, indent string) string

func IsValidURL

func IsValidURL(toTest string) bool

isValidUrl tests a string to determine if it is a well-structured url or not.

func Map added in v1.26.0

func Map[T1, T2 any](elems []T1, fn func(T1) T2) []T2

Map transfers the elements of its first argument using the result of the second fn(e)

func OpenInBrowser

func OpenInBrowser(url, browserType string) error

OpenInBrowser opens the url in a web browser based on OS and $BROWSER environment variable

func Pluralize

func Pluralize(num int, thing string) string

func PresentInIntSlice

func PresentInIntSlice(hay []int, needle int) bool

PresentInIntSlice take a Hay (Slice of Ints) and a Needle (int) and returns true based on whether or not the Needle is present in the hay.

func PresentInStringSlice

func PresentInStringSlice(hay []string, needle string) bool

PresentInStringSlice take a Hay (Slice of Strings) and a Needle (string) and returns true based on whether or not the Needle is present in the hay.

func PrettyTimeAgo

func PrettyTimeAgo(ago time.Duration) string

func RenderMarkdown

func RenderMarkdown(text, glamourStyle string) (string, error)

func RenderMarkdownWithoutIndentations

func RenderMarkdownWithoutIndentations(text, glamourStyle string) (string, error)

func ReplaceNonAlphaNumericChars

func ReplaceNonAlphaNumericChars(words, replaceWith string) string

ReplaceNonAlphaNumericChars : Replaces non alpha-numeric values with provided char/string

func StringToInt

func StringToInt(str string) int

func TimeToPrettyTimeAgo

func TimeToPrettyTimeAgo(d time.Time) string

Types

type EditorOptions

type EditorOptions struct {
	FileName      string
	Label         string
	Help          string
	Default       string
	AppendDefault bool
	HideDefault   bool
}

type ListTitleOptions

type ListTitleOptions struct {
	// Name of the List to be used in constructing Description and EmptyMessage if not provided.
	Name string
	// Page represents the page number of the current page
	Page int
	// CurrentPageTotal is the total number of items in current page
	CurrentPageTotal int
	// Total number of records. Default is the total number of rows.
	// Can be set to be greater than the total number of rows especially, if the list is paginated
	Total int
	// RepoName represents the name of the project or repository
	RepoName string
	// ListActionType should be either "search" or "list". Default is list
	ListActionType string
	// Optional. EmptyMessage to display when List is empty. If not provided, default one constructed from list Name.
	EmptyMessage string
}

func NewListTitle

func NewListTitle(listName string) ListTitleOptions

func (*ListTitleOptions) Describe

func (opts *ListTitleOptions) Describe() string

type MarkdownRenderOpts

type MarkdownRenderOpts []glamour.TermRendererOption

Jump to

Keyboard shortcuts

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