utils

package
v4.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 25 Imported by: 1

Documentation

Overview

19 types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddContentToEachLineInFile

func AddContentToEachLineInFile(filePath string, predicate func(string) string) error

func AddContentToFile

func AddContentToFile(filePath, valueToAdd string, positon string) error

func ArrayContainsAny added in v4.4.3

func ArrayContainsAny(contentSlice, targetSlice []string) bool

func CDToAngularApp

func CDToAngularApp()

func CDToFirebaseApp

func CDToFirebaseApp()

func CDToFlaskApp

func CDToFlaskApp()

func CDToFlutterApp

func CDToFlutterApp()

func CDToLocation

func CDToLocation(location string, opts ...interface{})

func CDToTestNGApp

func CDToTestNGApp()

func CDToWorkspaceRoot

func CDToWorkspaceRoot()

func ClearScreen

func ClearScreen()

Function to clear the console screen

func CompileGlobs added in v4.2.9

func CompileGlobs(patterns []string) []glob.Glob

CompileGlobs compiles the string patterns into glob.Glob objects.

func ContainsAny added in v4.1.0

func ContainsAny(s string, substrs []string) bool

func ConvertPathToOSFormat

func ConvertPathToOSFormat(inputPath string) string

func ConvertToBoolArray

func ConvertToBoolArray(input []interface{}) []bool

func ConvertToByteArray

func ConvertToByteArray(input []interface{}) []byte

func ConvertToComplex128Array

func ConvertToComplex128Array(input []interface{}) []complex128

func ConvertToComplex64Array

func ConvertToComplex64Array(input []interface{}) []complex64

func ConvertToFloat32Array

func ConvertToFloat32Array(input []interface{}) []float32

func ConvertToFloat64Array

func ConvertToFloat64Array(input []interface{}) []float64

func ConvertToInt16Array

func ConvertToInt16Array(input []interface{}) []int16

func ConvertToInt32Array

func ConvertToInt32Array(input []interface{}) []int32

func ConvertToInt64Array

func ConvertToInt64Array(input []interface{}) []int64

func ConvertToInt8Array

func ConvertToInt8Array(input []interface{}) []int8

func ConvertToIntArray

func ConvertToIntArray(input []interface{}) []int

func ConvertToInterfaceArray

func ConvertToInterfaceArray[T any](input []T) []interface{}

func ConvertToRuneArray

func ConvertToRuneArray(input []interface{}) []rune

func ConvertToStringArray

func ConvertToStringArray(input []interface{}) []string

func ConvertToStringBoolMap

func ConvertToStringBoolMap(originalMap map[string]interface{}) map[string]bool

func ConvertToStringComplex128Map

func ConvertToStringComplex128Map(originalMap map[string]interface{}) map[string]complex128

func ConvertToStringComplex64Map

func ConvertToStringComplex64Map(originalMap map[string]interface{}) map[string]complex64

func ConvertToStringErrorMap

func ConvertToStringErrorMap(originalMap map[string]interface{}) map[string]error

func ConvertToStringFloat32Map

func ConvertToStringFloat32Map(originalMap map[string]interface{}) map[string]float32

func ConvertToStringFloat64Map

func ConvertToStringFloat64Map(originalMap map[string]interface{}) map[string]float64

func ConvertToStringInt16Map

func ConvertToStringInt16Map(originalMap map[string]interface{}) map[string]int16

func ConvertToStringInt32Map

func ConvertToStringInt32Map(originalMap map[string]interface{}) map[string]int32

func ConvertToStringInt64Map

func ConvertToStringInt64Map(originalMap map[string]interface{}) map[string]int64

func ConvertToStringInt8Map

func ConvertToStringInt8Map(originalMap map[string]interface{}) map[string]int8

func ConvertToStringIntMap

func ConvertToStringIntMap(originalMap map[string]interface{}) map[string]int

func ConvertToStringInterfaceMap

func ConvertToStringInterfaceMap(originalMap map[string]interface{}) map[string]string

func ConvertToStringStringMap

func ConvertToStringStringMap(originalMap map[string]interface{}) map[string]string

func ConvertToStringUint16Map

func ConvertToStringUint16Map(originalMap map[string]interface{}) map[string]uint16

func ConvertToStringUint32Map

func ConvertToStringUint32Map(originalMap map[string]interface{}) map[string]uint32

func ConvertToStringUint64Map

func ConvertToStringUint64Map(originalMap map[string]interface{}) map[string]uint64

func ConvertToStringUint8Map

func ConvertToStringUint8Map(originalMap map[string]interface{}) map[string]uint8

func ConvertToUint16Array

func ConvertToUint16Array(input []interface{}) []uint16

func ConvertToUint32Array

func ConvertToUint32Array(input []interface{}) []uint32

func ConvertToUint64Array

func ConvertToUint64Array(input []interface{}) []uint64

func ConvertToUint8Array

func ConvertToUint8Array(input []interface{}) []uint8

func ConvertToUintArray

func ConvertToUintArray(input []interface{}) []uint

func CopyDir

func CopyDir(src, dest string) error

func CopyFile

func CopyFile(src, dest string) error

func CopySelectFilesToDestination

func CopySelectFilesToDestination(c CopySelectFilesToDestinationStruct) error

func DecreaseChannelBatchFn

func DecreaseChannelBatchFn(i int, batchSize int, batchDone chan bool, targetArray []string)

func DownloadFile added in v4.1.0

func DownloadFile(url, localPath string) error

func ExtractArchive added in v4.1.0

func ExtractArchive(archiveURL string, removeArchiveFile bool) string

func ExtractBranchNames

func ExtractBranchNames(input string) []string

func FilterArray

func FilterArray[T any](arr []T, condition func(interface{}, int) bool) []interface{}

func FilterFilesByExtension added in v4.5.5

func FilterFilesByExtension(files []string, extensions []string, include bool) []string

func FilterJSONByPredicate

func FilterJSONByPredicate(inputJSON []byte, predicate func(key string, value interface{}) bool) ([]byte, error)

func FilterMap

func FilterMap[T any](originalMap map[string]T, predicate func(string, T) bool) map[string]interface{}

func FindExecutable added in v4.1.0

func FindExecutable(executablePrefix, searchDir string) string

func FolderExists

func FolderExists(path string) bool

func GetCurrentBranch

func GetCurrentBranch() (string, error)

func GetCurrentPath

func GetCurrentPath() string

func GetDownloadURLForCurrentOS added in v4.1.0

func GetDownloadURLForCurrentOS(release *GitHubRelease) (string, error)

func GetInputFromStdin

func GetInputFromStdin(obj GetInputFromStdinStruct) string

func GetItemsInFolder

func GetItemsInFolder(folderPath string) ([]string, error)

func GetItemsInFolderRecursive

func GetItemsInFolderRecursive(folderPath string, recursive bool) ([]string, error)

func GetParamValue

func GetParamValue(parameterName string, parameterValue interface{}) interface{}

func GetSourceFilePath added in v4.1.0

func GetSourceFilePath() (string, error)

func GetType

func GetType(value interface{}) string

getType returns the type of a given value as a string

func GitSparseClone

func GitSparseClone(repoURL string, localDir string, subdirectories ...string) error

func HasPrefixInArray

func HasPrefixInArray(str string, prefixes []string, removeSuffix bool) string

func HasSuffixInArray

func HasSuffixInArray(str string, suffixes []string, removeSuffix bool) string

func IsFileOrFolder

func IsFileOrFolder(path string) (string, error)

func IsRunningInDocker

func IsRunningInDocker() bool

func JoinAndConvertPathToOSFormat

func JoinAndConvertPathToOSFormat(inputPathParts ...string) string

func MatchAnyGlob added in v4.2.9

func MatchAnyGlob(globs []glob.Glob, path string) bool

MatchAnyGlob checks if a path matches any of the provided glob patterns.

func MergeDirectories

func MergeDirectories(sourceDir, targetDir string, overwrite bool) error

func OverwriteFile

func OverwriteFile(filePath string, content string) error

func OverwriteMap

func OverwriteMap[T any](targetMap, newMap map[string]T)

func ProcessFilesMatchingPattern

func ProcessFilesMatchingPattern(directory, pattern string, predicateFn func(string)) error

func ProcessFoldersMatchingPattern

func ProcessFoldersMatchingPattern(directory, pattern string, predicateFn func(string)) error

func ReadFile

func ReadFile(filePath string) (string, error)

func RemoveComments added in v4.5.2

func RemoveComments(data []byte) ([]byte, error)

func RemoveContentFromFile added in v4.3.7

func RemoveContentFromFile(filePath string, contentToRemove []string) error

func RemoveDrivePath

func RemoveDrivePath(folderPath string) string

func RemoveElementsNotInSource added in v4.4.3

func RemoveElementsNotInSource[T comparable](source, toRemove []T) []T

func Reverse

func Reverse(targetArray []string) []string

func RunCommand deprecated

func RunCommand(command string, args []string)

Deprecated: This function will be removed in the next major release. Use RunCommandWithOptions instead.

func RunCommandAndGetOutput deprecated

func RunCommandAndGetOutput(command string, args []string) string

Deprecated: This function will be removed in the next major release. Use RunCommandWithOptions instead.

func RunCommandInSpecifcDirectoryAndGetOutput deprecated

func RunCommandInSpecifcDirectoryAndGetOutput(command string, args []string, targetDir string) string

Deprecated: This function will be removed in the next major release. Use RunCommandWithOptions instead.

func RunCommandInSpecificDirectory deprecated

func RunCommandInSpecificDirectory(command string, args []string, targetDir string)

Deprecated: This function will be removed in the next major release. Use RunCommandWithOptions instead.

func RunCommandWithOptions

func RunCommandWithOptions(options CommandOptions) (string, error)

func ShowMenu

func ShowMenu(cliInfo ShowMenuModel, enableOtherOption interface{}) string

func ShowMenuMultipleOptions added in v4.3.6

func ShowMenuMultipleOptions(cliInfo ShowMenuMultipleModel, enableOtherOption interface{}) []string

func TraverseDirectory

func TraverseDirectory(config TraverseDirectoryParams) error

func TruncateStringByRegex

func TruncateStringByRegex(options TruncateStringByRegexOptions) string

func UnicodeUnquote

func UnicodeUnquote(bs []byte) []byte

func WatchDirectory added in v4.2.5

func WatchDirectory(options WatchDirectoryParams)

func WriteCustomFormattedJSONToFile

func WriteCustomFormattedJSONToFile(data interface{}, filename string, indentString string) error

func WriteFormattoJSONFile

func WriteFormattoJSONFile(data interface{}, filename string)

Types

type AngularFrontendStruct

type AngularFrontendStruct struct {
	Configurations []string `json:"configurations"`
}

type CommandOptions

type CommandOptions struct {
	CmdObj             *exec.Cmd
	Self               *CommandOptions
	Command            string
	Args               []string
	TargetDir          string
	GetOutput          bool
	PrintOutput        bool
	PrintOutputOnly    bool
	PanicOnError       bool
	NonBlocking        bool
	IsInputFromProgram bool
}

func (CommandOptions) EndProcess added in v4.2.5

func (c CommandOptions) EndProcess() error

type CopySelectFilesToDestinationStruct

type CopySelectFilesToDestinationStruct struct {
	SourceFiles    []string
	GlobPattern    string //regex
	DestinationDir string
}

type CreateStringObjectType

type CreateStringObjectType struct {
	Orig       string
	Prefix     func() string
	CamelCase  func(stripSuffix bool, suffix string) string
	Classify   func(stripSuffix bool, suffix string) string
	Capitalize func(stripSuffix bool, suffix string) string
	Dasherize  func(stripSuffix bool, suffix string) string
	Lowercase  func(stripSuffix bool, suffix string) string
	Uppercase  func(stripSuffix bool, suffix string) string
	Snakecase  func(stripSuffix bool, suffix string) string
}

CreateStringObjectType represents the structure of the string object.

func CreateStringObject

func CreateStringObject(myStr string, entitySuffix string) (CreateStringObjectType, error)

type DualWriter added in v4.2.0

type DualWriter struct {
	TerminalWriter io.Writer
	Buffer         *bytes.Buffer
}

func (DualWriter) Write added in v4.2.0

func (w DualWriter) Write(p []byte) (n int, err error)

type GetInputFromStdinStruct

type GetInputFromStdinStruct struct {
	Prompt  []string
	ErrMsg  string
	Default string
}

type GetTestNGArgsStruct

type GetTestNGArgsStruct struct {
	WorkspaceFolder string
	EnvVarsFile     string
	TestNGFolder    string
	SuiteFile       string
	ParamEnv        string
}

type GitCloneSubdirsStruct

type GitCloneSubdirsStruct struct {
	RepoURL    string `json:"repoURL"`
	StagingDir string `json:"stagingDir"`
	Subdirs    string `json:"subdirs"`
	DestDir    string `json:"destDir"`
}

type GitHubRelease added in v4.1.0

type GitHubRelease struct {
	TagName string `json:"tag_name"`
	Assets  []struct {
		Name               string `json:"name"`
		BrowserDownloadURL string `json:"browser_download_url"`
	} `json:"assets"`
}

func GetLatestRelease added in v4.1.0

func GetLatestRelease(repoURL string) (*GitHubRelease, error)

type MiscOptimizeImagesStruct

type MiscOptimizeImagesStruct struct {
	Location        string `json:"location"`
	BackupLocation  string `json:"backupLocation"`
	OptimizePercent string `json:"optimizePercent"`
}

type ShellCommandOutput

type ShellCommandOutput struct{}

func (ShellCommandOutput) Write

func (c ShellCommandOutput) Write(p []byte) (int, error)

type ShowMenuModel

type ShowMenuModel struct {
	Default     string
	Other       bool
	OtherString string
	Prompt      string
	Choices     []string       // items on the to-do list
	Selected    map[int]string // which to-do items are selected
	// contains filtered or unexported fields
}

func (ShowMenuModel) Init

func (m ShowMenuModel) Init() tea.Cmd

func (ShowMenuModel) Update

func (m ShowMenuModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (ShowMenuModel) View

func (m ShowMenuModel) View() string

type ShowMenuMultipleModel added in v4.3.6

type ShowMenuMultipleModel struct {
	Defaults []string // Default selections
	Prompt   string
	Choices  []string       // Items on the list
	Selected map[int]string // Selected items

	Other             bool   // Enable 'Other' option
	OtherString       string // String for 'Other' option
	SelectionLimit    int    // Maximum number of selections allowed
	SelectedDelimiter string // Delimiter for selected items in the returned string
	// contains filtered or unexported fields
}

func (ShowMenuMultipleModel) Init added in v4.3.6

func (m ShowMenuMultipleModel) Init() tea.Cmd

func (ShowMenuMultipleModel) Update added in v4.3.6

func (m ShowMenuMultipleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (ShowMenuMultipleModel) View added in v4.3.6

func (m ShowMenuMultipleModel) View() string

type TakeVariableArgsResultStruct

type TakeVariableArgsResultStruct struct {
	InputString string
	InputArray  []string
}

type TakeVariableArgsStruct

type TakeVariableArgsStruct struct {
	Prompt    string
	ErrMsg    string
	Default   string
	Delimiter string
}

type TraverseDirectoryParams

type TraverseDirectoryParams struct {
	RootDir   string
	Predicate func(string, os.FileInfo)
	Filter    func(string, os.FileInfo) bool
}

type TruncateStringByRegexOptions

type TruncateStringByRegexOptions struct {
	InputString  string
	RegexPattern string
	Predicate    func(int) bool
}

type VSCodeSettings

type VSCodeSettings struct {
	ExtensionPack WindmillcodeExtensionPack `json:"windmillcode-extension-pack-0"`
}

func GetSettingsJSON

func GetSettingsJSON(workSpaceFolder string) (VSCodeSettings, error)

type WatchDirectoryParams added in v4.2.9

type WatchDirectoryParams struct {
	DirectoryToWatch string
	DebounceInMs     int
	Predicate        func(event fsnotify.Event)
	StartOnWatch     bool
	IncludePatterns  []string
	ExcludePatterns  []string
}

type WindmillcodeExtensionPack

type WindmillcodeExtensionPack struct {
	TasksToRunOnFolderOpen       []string                 `json:"tasksToRunOnFolderOpen"`
	FlaskBackendDevHelperScript  string                   `json:"flaskBackendDevHelperScript"`
	FlaskBackendTestHelperScript string                   `json:"flaskBackendTestHelperScript"`
	ProxyURLs                    string                   `json:"proxyURLs"`
	SQLDockerContainerName       string                   `json:"sqlDockerContainerName"`
	DatabaseName                 string                   `json:"databaseName"`
	DatabaseOptions              []string                 `json:"databaseOptions"`
	OpenAIAPIKey0                string                   `json:"openAIAPIKey0"`
	OpenAIAPIBase0               string                   `json:"openAIAPIBase0"`
	LangCodes0                   string                   `json:"langCodes0"`
	PythonVersion0               string                   `json:"pythonVersion0"`
	GitCloneSubdirs              GitCloneSubdirsStruct    `json:"gitCloneSubdirs"`
	MiscOptimizeImages           MiscOptimizeImagesStruct `json:"miscOptimizeImages"`
	AngularFrontend              AngularFrontendStruct    `json:"angularFrontend"`
}

Jump to

Keyboard shortcuts

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