utils

package
v5.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 25 Imported by: 0

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

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

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

CompileGlobs compiles the string patterns into glob.Glob objects.

func ContainsAny

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

func DownloadFile(url, localPath string) error

func EnsureDirAndCreateFile added in v5.0.2

func EnsureDirAndCreateFile(filePath string) (*os.File, error)

func ExtractArchive

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 v5.0.2

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

func FindExecutable(executablePrefix, searchDir string) string

func FindRelativeToTarget added in v5.1.1

func FindRelativeToTarget(args []string, target string, offset int) (string, bool)

func FolderExists

func FolderExists(path string) bool

func GetCurrentBranch

func GetCurrentBranch() (string, error)

func GetCurrentPath

func GetCurrentPath() string

func GetDownloadURLForCurrentOS

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

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

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 v5.0.2

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

func RemoveContentFromFile

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

func RemoveDrivePath

func RemoveDrivePath(folderPath string) string

func RemoveElementsNotInSource

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

func RemovePathPrefix added in v5.0.2

func RemovePathPrefix(path string, prefixArray []string) string

func Reverse

func Reverse(targetArray []string) []string

func RunCommand

func RunCommand(command string, args []string)

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

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

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 added in v5.0.2

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

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
	KebabCase  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

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

func (DualWriter) Write

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

type FlutterMobileBuild added in v5.0.4

type FlutterMobileBuild struct {
	ToolArgs                   []string `json:"toolArgs"`
	Args                       []string `json:"args"`
	VmAdditionalArgs           []string `json:"vmAdditionalArgs"`
	PlayStoreServiceAccountKey string   `json:"playStoreServiceAccountKey"`
	PackageName                string   `json:"packageName"`
	PublishTarget              string   `json:"publishTarget"`
	TrackName                  string   `json:"trackName"`
}

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 added in v5.0.2

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

type GitHubRelease

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

func GetLatestRelease

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

type MiscOptimizeImagesStruct added in v5.0.2

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

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

func (m ShowMenuMultipleModel) Init() tea.Cmd

func (ShowMenuMultipleModel) Update

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

func (ShowMenuMultipleModel) View

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 added in v5.0.2

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

func GetSettingsJSON added in v5.0.2

func GetSettingsJSON(workSpaceFolder string) (VSCodeSettings, error)

type WatchDirectoryParams

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

type WindmillcodeExtensionPack added in v5.0.2

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"`
	Environments                 []string                 `json:"environments"`
	SentryDSN                    string                   `json:"sentryDSN"`
	OpenAIAPIKey0                string                   `json:"openAIAPIKey0"`
	OpenAIAPIBase0               string                   `json:"openAIAPIBase0"`
	LangCodes0                   string                   `json:"langCodes0"`
	PythonVersion0               string                   `json:"pythonVersion0"`
	NodeJSVersion0               string                   `json:"nodeJSVersion0"`
	JavaVersion0                 string                   `json:"javaVersion0"`
	GoVersion0                   string                   `json:"goVersion0"`
	RubyVersion0                 string                   `json:"rubyVersion0"`
	DartVersion0                 string                   `json:"dartVersion0"`
	CSharpVersion0               string                   `json:"cSharpVersion0"`
	SwiftVersion0                string                   `json:"swiftVersion0"`
	PHPVersion0                  string                   `json:"phpVersion0"`
	RustVersion0                 string                   `json:"rustVersion0"`
	KotlinVersion0               string                   `json:"kotlinVersion0"`
	ScalaVersion0                string                   `json:"scalaVersion0"`
	PerlVersion0                 string                   `json:"perlVersion0"`
	LuaVersion0                  string                   `json:"luaVersion0"`
	HaskellVersion0              string                   `json:"haskellVersion0"`
	ClojureVersion0              string                   `json:"clojureVersion0"`
	ErlangVersion0               string                   `json:"erlangVersion0"`
	JuliaVersion0                string                   `json:"juliaVersion0"`
	ObjectiveCVersion0           string                   `json:"objectiveCVersion0"`
	FSharpVersion0               string                   `json:"fSharpVersion0"`
	VisualBasicVersion0          string                   `json:"visualBasicVersion0"`
	FlutterMobileBuild           FlutterMobileBuild       `json:"flutterMobileBuild"`
	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