utils

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// BaseColorList is color names list and their default values
	BaseColorList = map[string]string{
		"main_fg":                               "ffffff",
		"secondary_fg":                          "c0c0c0",
		"main_bg":                               "282828",
		"sidebar_and_player_bg":                 "000000",
		"cover_overlay_and_shadow":              "000000",
		"indicator_fg_and_button_bg":            "1db954",
		"pressing_fg":                           "cdcdcd",
		"slider_bg":                             "404040",
		"sidebar_indicator_and_hover_button_bg": "1ed660",
		"scrollbar_fg_and_selected_row_bg":      "333333",
		"pressing_button_fg":                    "cccccc",
		"pressing_button_bg":                    "179443",
		"selected_button":                       "18ac4d",
		"miscellaneous_bg":                      "4687d6",
		"miscellaneous_hover_bg":                "2e77d0",
		"preserve_1":                            "ffffff",
	}

	// BaseColorOrder is color name list in an order
	BaseColorOrder = []string{
		"main_fg",
		"secondary_fg",
		"main_bg",
		"sidebar_and_player_bg",
		"cover_overlay_and_shadow",
		"indicator_fg_and_button_bg",
		"pressing_fg",
		"slider_bg",
		"sidebar_indicator_and_hover_button_bg",
		"scrollbar_fg_and_selected_row_bg",
		"pressing_button_fg",
		"pressing_button_bg",
		"selected_button",
		"miscellaneous_bg",
		"miscellaneous_hover_bg",
		"preserve_1",
	}
)
View Source
var (
	// INTERVAL .
	INTERVAL = 200 * time.Millisecond
)

Functions

func Blue added in v0.9.1

func Blue(text string) string

Blue .

func Bold added in v0.4.1

func Bold(text string) string

Bold .

func CheckExistAndCreate

func CheckExistAndCreate(dir string)

CheckExistAndCreate checks folder existence and makes that folder, rescursively, if it does not exist

func CheckExistAndDelete added in v0.9.6

func CheckExistAndDelete(dir string)

CheckExistAndDelete checks folder existence and deletes that folder if it does 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 CreateJunction added in v0.7.0

func CreateJunction(location, destination string) error

CreateJunction creates a junction in Windows or a symlink in Linux/Mac.

func Fatal

func Fatal(err error)

Fatal prints fatal message and exits process

func FindAppPath added in v0.4.0

func FindAppPath() string

FindAppPath finds Spotify location in various possible places of each platform and returns it. Returns blank string if none of default locations exists.

func FindPrefFilePath added in v0.4.0

func FindPrefFilePath() string

FindPrefFilePath finds Spotify "prefs" file location in various possible places of each platform and returns it. Returns blank string if none of default locations exists.

func FindSymbol added in v0.5.0

func FindSymbol(debugInfo, content string, clues []string) []string

FindSymbol uses regexp from one or multiple clues to find variable or function symbol in obfursted code.

func GetDebuggerPath added in v1.0.0

func GetDebuggerPath() string

GetDebuggerPath fetches opening debugger list from localhost and returns the Spotify one.

func GetExecutableDir

func GetExecutableDir() string

GetExecutableDir returns directory of current process

func GetJsHelperDir

func GetJsHelperDir() string

GetJsHelperDir returns jsHelper directory in executable directory

func GetSpotifyVersion

func GetSpotifyVersion(prefsPath string) string

GetSpotifyVersion .

func Green added in v0.9.1

func Green(text string) string

Green .

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 message in red color

func PrintSuccess

func PrintSuccess(text string)

PrintSuccess prints a success message

func PrintWarning

func PrintWarning(text string)

PrintWarning prints a warning message

func Red added in v0.9.1

func Red(text string) string

Red .

func Replace

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

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

func SendReload added in v1.0.0

func SendReload(debuggerURL *string) error

SendReload sends reload command to debugger Websocket server

func Unzip

func Unzip(src, dest string) error

Unzip unzips zip

func Watch added in v0.8.0

func Watch(fileList []string, callbackEach func(fileName string, err error), callbackAfter func())

Watch .

func WatchRecursive added in v0.8.0

func WatchRecursive(root string, callbackEach func(fileName string, err error), callbackAfter func())

WatchRecursive .

func Yellow added in v0.9.1

func Yellow(text string) string

Yellow .

Types

type Color

type Color interface {
	Hex() string
	RGB() string
	TerminalRGB() 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 or from XResources or env variable 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 TernaryBool added in v0.9.1

type TernaryBool int

TernaryBool is three-way boolean: default, true, false

func (TernaryBool) IsDefault added in v0.9.1

func (b TernaryBool) IsDefault() bool

IsDefault .

func (TernaryBool) ToForceOperator added in v0.9.1

func (b TernaryBool) ToForceOperator() string

ToForceOperator .

func (TernaryBool) ToString added in v0.9.1

func (b TernaryBool) ToString() string

ToString .

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker is used to hold, update and print progress info to console.

func NewTracker

func NewTracker(total int) *Tracker

NewTracker creates new tracker instance

func (*Tracker) Finish

func (t *Tracker) Finish()

Finish prints success message

func (*Tracker) Reset

func (t *Tracker) Reset()

Reset .

func (*Tracker) Update

func (t *Tracker) Update(name string)

Update increases progress count and prints current progress.

Jump to

Keyboard shortcuts

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