utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2018 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckExistAndCreate

func CheckExistAndCreate(dir string)

CheckExistAndCreate checks folder existence and make that folder if it does not exist

func Copy added in v0.3.0

func Copy(src, dest string, recursive bool, filters []string) error

Copy .

func CopyFile added in v0.3.0

func CopyFile(srcPath, dest string) error

CopyFile .

func Fatal

func Fatal(err error)

Fatal prints fatal message and exits process

func FindFlag added in v0.3.0

func FindFlag(args []string, flags ...string) bool

FindFlag finds flags in arrays of arguments returns true if one of requested flags is found

func GetExecutableDir

func GetExecutableDir() string

GetExecutableDir returns directory of current process

func GetJsHelperDir

func GetJsHelperDir() string

GetJsHelperDir retuns jsHelper directory in executable directory

func GetPrefsCfg

func GetPrefsCfg(spotifyPath string) (*ini.File, string, error)

GetPrefsCfg finds `prefs` file path based on OS and returns an `ini.File` ref.

func GetSpotifyVersion

func GetSpotifyVersion(spotifyPath string) string

GetSpotifyVersion .

func ModifyFile

func ModifyFile(path string, repl func(string) string)

ModifyFile opens file, changes file content by executing `repl` callback function and writes new content.

func PrependTime added in v0.3.0

func PrependTime(text string) string

PrependTime prepends current time string to text and returns new string

func PrintBold

func PrintBold(text string)

PrintBold prints a bold message

func PrintError

func PrintError(text string)

PrintError prints an error message

func PrintGreen

func PrintGreen(text string)

PrintGreen prints a message in green color

func PrintInfo

func PrintInfo(text string)

PrintInfo prints an info message

func PrintRed

func PrintRed(text string)

PrintRed prints a red message

func PrintSuccess

func PrintSuccess(text string)

PrintSuccess prints a success message

func PrintWarning

func PrintWarning(text string)

PrintWarning prints a warning message

func ReadAnswer

func ReadAnswer(info string, defaultAnswer bool) bool

ReadAnswer prints out a yes/no form with string from `info` and returns boolean value based on user input (y/Y or n/N) or return `defaultAnswer` if input is omitted. If input is neither of them, print form again.

func Replace

func Replace(input string, regexpTerm string, replaceTerm string) string

Replace uses Regexp to find any matched from `input` with `regexpTerm` and replaces them with `replaceTerm` then returns new string.

func RestartSpotify

func RestartSpotify(spotifyPath string)

RestartSpotify .

func Unzip

func Unzip(src, dest string) error

Unzip unzips zip

Types

type Color

type Color interface {
	Hex() string
	RGB() string
}

Color stores hex and rgb value of color

func ParseColor

func ParseColor(raw string) Color

ParseColor parses a string in both hex or rgb and converts to both rgb and hex value

type Config

type Config interface {
	Write()
	GetSection(string) *ini.Section
	GetPath() string
}

Config .

func ParseConfig

func ParseConfig(configPath string) Config

ParseConfig read config file content, return default config if file doesn't exist.

type Tracker

type Tracker interface {
	Update(name string, err error)
	Finish()
	Reset()
	Quiet()
}

Tracker is a counter

func NewTracker

func NewTracker(total int) Tracker

NewTracker creates new tracker instance

Jump to

Keyboard shortcuts

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