cmdhandle

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2020 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	// ExitOk the process was executed without errors
	ExitOk = 0
	// ExitByStopReason the process stopped because of a defined reason
	ExitByStopReason = 101
	// ExitNoCode means there was no code associated
	ExitNoCode = 102
	// ExitCmdError means the execution of the command fails. a error by the command itself
	ExitCmdError = 103
	// ExitByRequirement means a requirement was not fulfills
	ExitByRequirement = 104
	// ExitAlreadyRunning means the task is not started, because it is already created
	ExitAlreadyRunning = 105
)
View Source
const (
	// DefaultExecFile is the filename of the script defaut file
	DefaultExecFile = "/.context.json"

	// DefaultExecYaml is the default yaml configuration file
	DefaultExecYaml = "/.contxt.yml"

	// TargetScript is script default target
	TargetScript = "script"

	// InitScript is script default target
	InitScript = "init"

	// ClearScript is script default target
	ClearScript = "clear"

	// TestScript is teh test target
	TestScript = "test"

	// DefaultCommandFallBack is used if no command is defined
	DefaultCommandFallBack = "bash"

	// On windows we have a different default
	DefaultCommandFallBackWindows = "powershell"
)

Variables

View Source
var Experimental = false

this flag is for the runner logic replacement that have still issues. this 'solution' is not nice but a different branch would be more difficult to handle

Functions

func AddData

func AddData(key string, data map[string]interface{})

AddData adds a Data Map to the storage

func AddJSON

func AddJSON(key, jsonString string) error

AddJSON imports data by a json String

func BashUser

func BashUser()

func CheckOrCreateUseConfig added in v0.2.2

func CheckOrCreateUseConfig(externalUseCase string) (string, error)

CheckOrCreateUseConfig get a usecase like swaros/ctx-git and checks if a local copy of them exists. if they not exists it creates the local directoy and uses git to clone the content. afterwards it writes a version.conf in the forlder above of content and stores the current hashes

func ClearAll

func ClearAll()

ClearAll removes all entries

func ClearAllData

func ClearAllData()

ClearAllData removes all entries

func CreateImport

func CreateImport(path string, pathToAdd string) error

CreateImport creates import settings

func CreateMirror

func CreateMirror(path string)

CreateMirror creates nested directories

func ExecPathFile

func ExecPathFile(waitGroup *sync.WaitGroup, useWaitGroup bool, template configure.RunConfig, target string) int

ExecPathFile executes the default exec file

func ExecuteScriptLine

func ExecuteScriptLine(ShellToUse string, cmdArg []string, command string, callback func(string) bool, startInfo func(*os.Process)) (int, int, error)

ExecuteScriptLine executes a simple shell script returns internal exitsCode, process existcode, error

func ExecuteTemplateWorker

func ExecuteTemplateWorker(waitGroup *sync.WaitGroup, useWaitGroup bool, target string, template configure.RunConfig)

ExecuteTemplateWorker runs ExecCurrentPathTemplate in context of a waitgroup

func ExistInStrMap

func ExistInStrMap(testStr string, check []string) bool

func ExportTask

func ExportTask(target string) (string, error)

func FindTemplate

func FindTemplate() (string, bool)

FindTemplate searchs for Template files in different spaces

func FishCompletionUpdate

func FishCompletionUpdate(cmd *cobra.Command)

func FishFunctionUpdate

func FishFunctionUpdate()

func FishUpdate

func FishUpdate(cmd *cobra.Command)

func GetArgQuotedEntries

func GetArgQuotedEntries(oristr string) ([]string, bool)

func GetData

func GetData(key string) (bool, map[string]interface{})

GetData returns a data Map by the key. or nil if nothing is stored

func GetDataKeys

func GetDataKeys() []string

GetDataKeys returns all current keys

func GetDefaultCmd

func GetDefaultCmd() string

func GetDefaultCmdOpts

func GetDefaultCmdOpts(ShellToUse string, cmdArg []string) []string

func GetExecDefaults

func GetExecDefaults() (string, []string)

func GetJSONPathResult

func GetJSONPathResult(key, path string) (gjson.Result, bool)

GetJSONPathResult returns the value depending key and path as string

func GetJSONPathValueString

func GetJSONPathValueString(key, path string) string

GetJSONPathValueString returns the value depending key and path as string

func GetLogger

func GetLogger() *logrus.Logger

GetLogger is the main Logger instance

func GetOriginMap

func GetOriginMap() map[string]interface{}

func GetPH

func GetPH(key string) string

GetPH the content of the key. but at least a empty string if not exists. so this is not usefull to test if the PH was set.

func GetPHExists

func GetPHExists(key string) (string, bool)

GetPH the content of the key as string. if exists.

func GetParsedTemplateSource

func GetParsedTemplateSource(path string) (string, error)

GetParsedTemplateSource Returns the soucecode of the template including parsing placeholders

func GetPwdTemplate

func GetPwdTemplate(path string) (configure.RunConfig, error)

GetPwdTemplate returns the template path if exists. it also parses the content of the template against imports and handles them

func GetTemplate

func GetTemplate() (configure.RunConfig, string, bool, error)

GetTemplate return current template

func GetUseInfo added in v0.2.2

func GetUseInfo(usecase, pathTouse string) (string, string)

func HandleJSONMap

func HandleJSONMap(tmpl string, m map[string]interface{}) (string, error)

HandleJSONMap parsing json content for text/template

func HandlePlaceHolder

func HandlePlaceHolder(line string) string

HandlePlaceHolder replaces all defined placeholders

func HandlePlaceHolderWithScope added in v0.2.2

func HandlePlaceHolderWithScope(line string, scopeVars map[string]string) string

func HandleUsecase

func HandleUsecase(externalUseCase string) string

func ImportDataFromJSONFile

func ImportDataFromJSONFile(key string, filename string) error

ImportDataFromJSONFile imports a map from a json file and assign it to a key

func ImportDataFromYAMLFile

func ImportDataFromYAMLFile(key string, filename string) error

ImportDataFromYAMLFile imports a map from a json file and assign it to a key

func ImportFileContent

func ImportFileContent(filename string) (string, error)

ImportFileContent imports a file and returns content as string

func ImportFolder

func ImportFolder(path string, templatePath string) (map[string]interface{}, error)

ImportFolder reads folder recursiv and reads all .json, .yml and .yaml files

func ImportFolders

func ImportFolders(templatePath string, paths ...string) (string, error)

ImportFolders import a list of folders recusiv

func ImportJSONFile

func ImportJSONFile(fileName string) (map[string]interface{}, error)

ImportJSONFile imports a json file for reading

func ImportYAMLFile

func ImportYAMLFile(filename string) (map[string]interface{}, error)

ImportYAMLFile imports a yaml file as used for json map

func InitDefaultVars

func InitDefaultVars()

func LintOut

func LintOut(leftcnt, rightcnt int, all bool, noOut bool) bool

LintOut prints the source code and the parsed content in a table view, and marks configured and not configured entries with dfferent colors

func ListUseCases

func ListUseCases(fullPath bool) ([]string, error)

func LoadIncTempalte

func LoadIncTempalte(path string) (string, bool)

LoadIncTempalte check if .inc.contxt.yml files exists and if this is the case the content will be loaded and all defined paths used to get values for parsing the template file

func MainExecute

func MainExecute()

MainExecute runs main. parsing flags

func MergeVariableMap

func MergeVariableMap(mapin map[string]interface{}, maporigin map[string]interface{}) map[string]interface{}

MergeVariableMap merges two maps

func ResetAllTaskInfos

func ResetAllTaskInfos()

ResetAllTaskInfos resets all task infos

func RunShared

func RunShared(targets string)

func RunTargets

func RunTargets(targets string, sharedRun bool)

RunTargets executes multiple targets the targets string can have multiple targets seperated by comma

func SetIfNotExists

func SetIfNotExists(key, value string)

func SetPH

func SetPH(key, value string)

SetPH add key value pair

func SharedFolderExecuter

func SharedFolderExecuter(template configure.RunConfig, locationHandle func(string, string))

func ShowAsYaml

func ShowAsYaml(fullparsed bool, trySupress bool, indent int)

ShowAsYaml prints the generated source of the task file

func SplitArgs added in v0.2.2

func SplitArgs(cmdList []string, prefix string, arghandler func(string, map[string]string)) []string

func SplitQuoted

func SplitQuoted(oristr string, sep string) []string

func StringMatchTest

func StringMatchTest(pattern, value string) bool

StringMatchTest test a pattern and a value. in this example: myvar: "=hello" the patter is "=hello" and the value should be "hello" for a match

func StringSplitArgs added in v0.2.2

func StringSplitArgs(argLine string, prefix string) (string, map[string]string)

func StripContxtUseDir

func StripContxtUseDir(path string) string

func TaskExists

func TaskExists(target string) bool

TaskExists checks if a tak is already created

func TaskRunning

func TaskRunning(target string) bool

TaskRunning checks if a task is already running

func TestTemplate added in v0.2.2

func TestTemplate() error

func TryParse

func TryParse(script []string, regularScript func(string) (bool, int)) (bool, int, []string)

TryParse to parse a line and set a value depending on the line command

func UpdateOriginMap

func UpdateOriginMap(mapData map[string]interface{})

func UpdateUseCase

func UpdateUseCase(fullPath string)

func UserDirectory

func UserDirectory() (string, error)

func WaitAtGroup added in v0.2.2

func WaitAtGroup(futures []Future) []interface{}

WaitAtGroup wait until all Futures are executes

func WaitForTasksDone

func WaitForTasksDone(tasks []string, timeOut, tickTime time.Duration, stillWait func() bool, isDone func(), timeOutHandle func(), notStartet func(string, string, map[string]string) bool)

WaitForTasksDone waits until all the task are done triggers a callback for any tick and one if the state DONE is reached there is an timeout as maximum time to wait if this time is reached the process will be continued and the timeout callback is triggered the callback for notStarted must return true if they handle this issue. on returning false it will be counted as isDone

func WriteFileIfNotExists

func WriteFileIfNotExists(filename, content string) (int, error)

func WriteTemplate

func WriteTemplate()

WriteTemplate create path based execution file

func YAMLToMap

func YAMLToMap(source string) (map[string]interface{}, error)

YAMLToMap Convert yaml source string into map

func ZshFuncDir added in v0.2.2

func ZshFuncDir() string

try to get the best path by reading the permission because zsh seems not be used in windows, we stick to linux related permission check

func ZshUpdate

func ZshUpdate(cmd *cobra.Command)

func ZshUser

func ZshUser()

Types

type CtxKey added in v0.2.2

type CtxKey struct{}

CtxKey is just the global key for the arguments

type Future added in v0.2.2

type Future interface {
	Await() interface{}
}

Future interface has the method signature for await

func ExecFuture added in v0.2.2

func ExecFuture(arg interface{}, f func() interface{}) Future

ExecFuture executes the async function and set the the argument

func ExecFutureGroup added in v0.2.2

func ExecFutureGroup(fg []FutureStack) []Future

ExecFutureGroup executes an group of Futures and returns assotiated future handler

type FutureStack added in v0.2.2

type FutureStack struct {
	AwaitFunc func(ctx context.Context) interface{}
	Argument  interface{}
}

FutureStack struct contains the AwaitFunc and argurments

note: this mght not the best way to handle the argument delivery see: https://go.dev/blog/context#TOC_3.2.

func (FutureStack) Await added in v0.2.2

func (f FutureStack) Await() interface{}

Await creates the context including arfgument, and blocks til any execution is done.

type TaskDef

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

TaskDef holds information about running and finished tasks

type TaskGroup added in v0.2.2

type TaskGroup struct {
	Awaits []Future // Future channels
	// simple callback that can be used for regular output or loggings
	LoggerFnc func(...interface{})
	// contains filtered or unexported fields
}

func CreateMultipleTask added in v0.2.2

func CreateMultipleTask(tasks []string, modifyTask func(*TaskWatched)) *TaskGroup

func (*TaskGroup) AddTask added in v0.2.2

func (Tg *TaskGroup) AddTask(name string, wg TaskWatched) *TaskGroup

func (*TaskGroup) Exec added in v0.2.2

func (Tg *TaskGroup) Exec() *TaskGroup

func (*TaskGroup) GetTask added in v0.2.2

func (Tg *TaskGroup) GetTask(name string) (bool, TaskWatched)

func (*TaskGroup) Log added in v0.2.2

func (Tg *TaskGroup) Log(msg ...interface{})

func (*TaskGroup) Wait added in v0.2.2

func (Tg *TaskGroup) Wait(wait time.Duration, timeOut time.Duration)

Wait until all task are done, indepenet from any channel and waitgroup blocks

type TaskResult added in v0.2.2

type TaskResult struct {
	Error   error
	Content interface{}
}

simple container used to get the result from task

func CreateTaskResult added in v0.2.2

func CreateTaskResult(err error) TaskResult

helper to creates a task result

func CreateTaskResultContent added in v0.2.2

func CreateTaskResultContent(err error, content interface{}) TaskResult

helper to creates a task result

type TaskRuntimeState added in v0.2.2

type TaskRuntimeState struct {
	// flag that will be true if the task is started already. or start is initiated
	Started bool
	// flag that is true if the task is timed out. not equals to Done
	TimedOut bool
	// flag if task is done
	Done bool
	// the runId. equals to the taskname
	RunId string
}

type TaskWatched added in v0.2.2

type TaskWatched struct {

	// arguments for the task
	TaskArgs map[string]string
	// if true, no error will be raised, if the same task will tried to be executed twice
	NoErrorIfBlocked bool
	// maximum of allowed runtime for the task
	TimeOutTiming time.Duration
	// optional callback. if set, these function is called. that is ment to be informed and for doing some cleanups.
	// but it can not interrupt the timeeout.
	TimeOutHandler func()
	// optional callback. this method can decide, if this task could be started again.
	// so this method will be executed only on the second try to run this task.
	CanRunAgain func(*TaskWatched) bool
	// can be set to define a custom taskid by some logic
	GetRunId func() string
	// the main function that contains the logic
	Exec func(*TaskWatched) TaskResult
	// simple callback that can be used for regular output or loggings
	LoggerFnc func(...interface{})
	// if true, the task will be started async.
	Async bool
	// callback for the execution result
	ResultFnc func(TaskResult)
	// contains filtered or unexported fields
}

func (*TaskWatched) GetName added in v0.2.2

func (t *TaskWatched) GetName() string

func (*TaskWatched) Init added in v0.2.2

func (t *TaskWatched) Init(name string)

func (*TaskWatched) IsRunning added in v0.2.2

func (t *TaskWatched) IsRunning() bool

func (*TaskWatched) Log added in v0.2.2

func (t *TaskWatched) Log(msg ...interface{})

func (*TaskWatched) ReportDone added in v0.2.2

func (t *TaskWatched) ReportDone()

func (*TaskWatched) Run added in v0.2.2

func (t *TaskWatched) Run() TaskResult

Jump to

Keyboard shortcuts

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