package
0.0.0-20240919144758-04d94ccb2297
Repository: https://github.com/overmindtech/pterm.git
Documentation: pkg.go.dev

# README

PUtils - PTerm Utils

Package putils contains utility functions for PTerm, to make it's usage even easier!
It contains pre-made functions, that utilize PTerm, to print various stuff to the terminal.
You can use PUtils, to simplify various scenarios for which PTerm is frequently used.\

You can read the documentation of this package here.

Feel free to contribute your utility functions via pull request!

Util Functions

func BulletListFromString(s string, padding string) pterm.BulletListPrinter
func BulletListFromStrings(s []string, padding string) pterm.BulletListPrinter
func BulletListItemFromString(text string, padding string) pterm.BulletListItem
func CenterText(text string) string
func DefaultTableFromStructSlice(structSlice interface{}) *pterm.TablePrinter
func DownloadFileWithDefaultProgressbar(title, outputPath, url string, mode os.FileMode) error
func DownloadFileWithProgressbar(progressbar *pterm.ProgressbarPrinter, outputPath, url string, mode os.FileMode) error
func LettersFromString(text string) pterm.Letters
func LettersFromStringWithRGB(text string, rgb pterm.RGB) pterm.Letters
func LettersFromStringWithStyle(text string, style *pterm.Style) pterm.Letters
func PrintAverageExecutionTime(count int, f func(i int) error) error
func RGBFromHEX(hex string) (pterm.RGB, error)
func RunWithDefaultSpinner(initzialSpinnerText string, f func(spinner *pterm.SpinnerPrinter) error) error
func RunWithSpinner(spinner *pterm.SpinnerPrinter, f func(spinner *pterm.SpinnerPrinter) error) error
func TableDataFromCSV(csv string) (td pterm.TableData)
func TableDataFromSeparatedValues(text, valueSeparator, rowSeparator string) (td pterm.TableData)
func TableDataFromTSV(csv string) (td pterm.TableData)
func TableFromStructSlice(tablePrinter pterm.TablePrinter, structSlice interface{}) *pterm.TablePrinter
func TreeFromLeveledList(leveledListItems pterm.LeveledList) pterm.TreeNode

# Functions

BulletListFromString returns a BulletListPrinter with Text using the NewTreeListItemFromString method, splitting after return (\n).
BulletListFromStrings returns a BulletListPrinter with Text using the NewTreeListItemFromString method.
BulletListItemFromString returns a BulletListItem with a Text.
CenterText returns a centered string with each line centered in respect to the longest line.
DefaultTableFromStructSlice will be populate the pterm.DefaultTable with the values of the structs.
DownloadFileWithDefaultProgressbar downloads a file, by url, and writes it to outputPath.
DownloadFileWithProgressbar downloads a file, by url, and writes it to outputPath.
LettersFromString creates a Letters object from a string, which is prefilled with the LetterStyle from ThemeDefault.
LettersFromStringWithRGB creates a Letters object from a string and applies an RGB color to it (overwrites style).
LettersFromStringWithStyle creates a Letters object from a string and applies a Style to it.
PrintAverageExecutionTime times the average execution time of a function.
RGBFromHEX converts a HEX and returns a new RGB.
RunWithDefaultSpinner starts a default spinner, then runs a function and after the function is done, the spinner will stop again.
RunWithSpinner starts a spinner, then runs a function and after the function is done, the spinner will stop again.
TableDataFromCSV converts CSV data into pterm.TableData.
TableDataFromSeparatedValues converts values, separated by separator, into pterm.TableData.
TableDataFromTSV converts TSV data into pterm.TableData.
TableFromStructSlice accepts a customized table printer and and a slice of a struct.
TreeFromLeveledList converts a TreeItems list to a TreeNode and returns it.