errcmd

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 27 Imported by: 11

Documentation

Index

Constants

View Source
const (
	InvalidExitCode             = consts.InvalidExitCode
	SuccessfullyRunningExitCode = consts.CmdSuccessfullyRunningExitCode
	ScriptsMultiLineJoiner      = " && \\ \n" // " && \\ \n"
	SingleLineScriptsJoiner     = " && "      // " && "

)

Variables

View Source
var (
	NewShellScript = &newCmdOnceTypedScriptsCreator{
		scriptType: scripttype.Shell,
	}
	NewBashScript = &newCmdOnceTypedScriptsCreator{
		scriptType: scripttype.Bash,
	}

	New = &newCreator{
		ShellScript: NewShellScript,
		BashScript:  NewBashScript,
	}
)

Functions

func ArgsJoin added in v0.5.1

func ArgsJoin(args ...string) string

func ArgsJoinPrepend added in v0.7.1

func ArgsJoinPrepend(argPrepend string, args ...string) string

func ArgsJoinSlice added in v0.5.1

func ArgsJoinSlice(args []string) string

func ArgsJoinSlicePtr added in v0.5.1

func ArgsJoinSlicePtr(args *[]string) string

func ArgsJoinWithSingle added in v0.6.5

func ArgsJoinWithSingle(arg1 string, args ...string) string

func BufferClone added in v0.9.6

func BufferClone(buffer *bytes.Buffer) *bytes.Buffer

func ClearDispose added in v0.9.2

func ClearDispose(cmdOnceRan *CmdOnce)

func CmdSetOsStandardWriters added in v0.9.6

func CmdSetOsStandardWriters(cmd *exec.Cmd) *exec.Cmd

func CmdToScriptLine added in v0.9.6

func CmdToScriptLine(cmd *exec.Cmd) string

func CombinedOutputError added in v0.8.0

func CombinedOutputError(
	stdIn *StdIn,
	processName string,
	args ...string,
) *cmdCompiledOutput

CombinedOutputError

stdIn can be nil

func CurrentOsDetails added in v0.9.6

func CurrentOsDetails() (*osmixtype.OperatingSystemDetail, *errorwrapper.Wrapper)

func GetExitCode added in v0.7.3

func GetExitCode(
	errorWrapper coreinterface.IsEmptyChecker,
	exitError *exec.ExitError,
) int

func GetFormattedKeyValueData added in v0.9.6

func GetFormattedKeyValueData(
	varName string,
	varValue string,
) string

GetFormattedKeyValueData "MY_VAR=some_value"

func InvalidCmdCompiledOutput added in v0.8.0

func InvalidCmdCompiledOutput(
	err error,
	process string,
	args []string,
) *cmdCompiledOutput

func ProcessArgsJoinAppend added in v0.9.6

func ProcessArgsJoinAppend(process string, args ...string) string

Types

type BaseCmdWrapper

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

func (*BaseCmdWrapper) Dispose added in v0.7.9

func (it *BaseCmdWrapper) Dispose()

func (*BaseCmdWrapper) DisposeWithoutErrorWrapper added in v0.8.9

func (it *BaseCmdWrapper) DisposeWithoutErrorWrapper()

type CmdOnce

type CmdOnce struct {
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

func Conditional added in v0.6.5

func Conditional(
	isTrue bool,
	trueCmdOne, falseCmdOnce *CmdOnce,
) *CmdOnce

func (*CmdOnce) AddEnvVar

func (it *CmdOnce) AddEnvVar(
	varName, varValue string,
) *CmdOnce

AddEnvVar cannot add slice if already executed. Warning : panic if called after execution.

func (*CmdOnce) AddEnvVarKeyVal

func (it *CmdOnce) AddEnvVarKeyVal(keyVal corestr.KeyValuePair) *CmdOnce

AddEnvVarKeyVal cannot add slice if already executed. Warning : panic if called after execution.

func (*CmdOnce) AddEnvVarsHashmap

func (it *CmdOnce) AddEnvVarsHashmap(
	hashmap *corestr.Hashmap,
) *CmdOnce

AddEnvVarsHashmap

cannot add slice if already executed. Warning : panic if called after execution.

func (*CmdOnce) AddEnvVarsSlice

func (it *CmdOnce) AddEnvVarsSlice(
	slice ...string,
) *CmdOnce

AddEnvVarsSlice

cannot add slice if already executed. Warning : panic if called after execution. Data needs to be in this format "MY_VAR=some_value"

func (*CmdOnce) Arguments

func (it *CmdOnce) Arguments() []string

func (*CmdOnce) ArgumentsSingleLine

func (it *CmdOnce) ArgumentsSingleLine() string

ArgumentsSingleLine Arguments Compiled using Space

func (*CmdOnce) Clone

func (it *CmdOnce) Clone() *CmdOnce

Clone calls constructor Lines to create itself using the existing data.

func (*CmdOnce) CloneCmd

func (it *CmdOnce) CloneCmd(isUseStd bool) *exec.Cmd

CloneCmd Clones and creates a new cmd

If isUseStd true then it will clone it-self and returns the cmd and buffer will be created and injected,

or else it will heavily depend on CompiledOutput or CombinedOutput

func (*CmdOnce) CmdCloneCompiledOutputBytes added in v0.7.9

func (it *CmdOnce) CmdCloneCompiledOutputBytes() (cmd *exec.Cmd, allBytes []byte, err error)

func (*CmdOnce) CmdCloneCompiledOutputString added in v0.7.9

func (it *CmdOnce) CmdCloneCompiledOutputString() (fullOutput corestr.SimpleStringOnce, err error)

func (*CmdOnce) CmdCloneCompiledOutputStringLines added in v0.7.9

func (it *CmdOnce) CmdCloneCompiledOutputStringLines() (fullOutputLines []string, err error)

func (*CmdOnce) CmdCloneCompiledOutputTrimStringLines added in v0.7.9

func (it *CmdOnce) CmdCloneCompiledOutputTrimStringLines() (fullOutputLines []string, err error)

func (*CmdOnce) CmdCloneUsingStds added in v0.7.9

func (it *CmdOnce) CmdCloneUsingStds(
	outBuff, errBuff *bytes.Buffer,
) *exec.Cmd

func (*CmdOnce) CmdCloneWithoutStd added in v0.7.9

func (it *CmdOnce) CmdCloneWithoutStd() *exec.Cmd

func (*CmdOnce) CommandLine

func (it *CmdOnce) CommandLine() string

CommandLine Gets commandline based on security. if receiver.hasSecureData then only returns process name

func (*CmdOnce) CompiledError

func (it *CmdOnce) CompiledError() string

CompiledError returns lazy once result.

Developer may check:

  • IsSuccessfullyExecuted() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • HasAnyIssues() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • isAlreadyRan() reveals already executed or not. Doesn't run the process. Or,
  • HasCmd() reveals if cmd is nil or not. Or,
  • HasIssues() reveals any issues before running cmd. Or,
  • CompiledErrorWrapper() to check the final error condition.

func (*CmdOnce) CompiledErrorBytes

func (it *CmdOnce) CompiledErrorBytes() []byte

CompiledErrorBytes returns lazy once result.

Developer may check:

  • IsSuccessfullyExecuted() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • HasAnyIssues() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • isAlreadyRan() reveals already executed or not. Doesn't run the process. Or,
  • HasCmd() reveals if cmd is nil or not. Or,
  • HasIssues() reveals any issues before running cmd. Or,
  • CompiledErrorWrapper() to check the final error condition.

func (*CmdOnce) CompiledErrorLines

func (it *CmdOnce) CompiledErrorLines() []string

CompiledErrorLines returns lazy once result.

Developer may check:

  • IsSuccessfullyExecuted() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • HasAnyIssues() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • isAlreadyRan() reveals already executed or not. Doesn't run the process. Or,
  • HasCmd() reveals if cmd is nil or not. Or,
  • HasIssues() reveals any issues before running cmd. Or,
  • CompiledErrorWrapper() to check the final error condition.

func (*CmdOnce) CompiledErrorWrapper

func (it *CmdOnce) CompiledErrorWrapper() *errorwrapper.Wrapper

CompiledErrorWrapper

Runs CmdOnce

using RunOnce then returns the final compiled error

func (*CmdOnce) CompiledErrorWrapperWithErrorBufferBytes added in v0.8.9

func (it *CmdOnce) CompiledErrorWrapperWithErrorBufferBytes() (
	errorBufferBytes []byte, compiledErrorWrapper *errorwrapper.Wrapper,
)

CompiledErrorWrapperWithErrorBufferBytes

Runs CmdOnce

using RunOnce then returns the final compiled error with error buffer lines

Calls Result.AllErrorBytes() Here, the value in result represent the buffer error bytes (from std) and error wrapper represents the compiled ErrorWrapper

func (*CmdOnce) CompiledErrorWrapperWithErrorBufferLine added in v0.8.9

func (it *CmdOnce) CompiledErrorWrapperWithErrorBufferLine() (
	errorBufferLine string, compiledErrorWrapper *errorwrapper.Wrapper,
)

CompiledErrorWrapperWithErrorBufferLine

Runs CmdOnce

using RunOnce then returns the final compiled error with error buffer lines

Calls Result.AllErrorString() Here, the value in result represent the buffer error string (from std) and error wrapper represents the compiled ErrorWrapper

func (*CmdOnce) CompiledFullErrorWrapper added in v0.8.9

func (it *CmdOnce) CompiledFullErrorWrapper() *errorwrapper.Wrapper

CompiledFullErrorWrapper

Represents compiled error wrapper + std error line

(if baseBufferStdOutError has any error bytes)

func (*CmdOnce) CompiledOutput

func (it *CmdOnce) CompiledOutput() string

CompiledOutput returns lazy once result.

Developer may check:

  • IsSuccessfullyExecuted() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • HasAnyIssues() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • isAlreadyRan() reveals already executed or not. Doesn't run the process. Or,
  • HasCmd() reveals if cmd is nil or not. Or,
  • HasIssues() reveals any issues before running cmd. Or,
  • CompiledErrorWrapper() to check the final error condition.

func (*CmdOnce) CompiledOutputBytes

func (it *CmdOnce) CompiledOutputBytes() []byte

CompiledOutputBytes returns lazy once result.

Developer may check:

  • IsSuccessfullyExecuted() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • HasAnyIssues() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • isAlreadyRan() reveals already executed or not. Doesn't run the process. Or,
  • HasCmd() reveals if cmd is nil or not. Or,
  • HasIssues() reveals any issues before running cmd. Or,
  • CompiledErrorWrapper() to check the final error condition.

func (*CmdOnce) CompiledOutputLines

func (it *CmdOnce) CompiledOutputLines() []string

CompiledOutputLines returns lazy once result.

Developer may check:

  • IsSuccessfullyExecuted() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • HasAnyIssues() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • isAlreadyRan() reveals already executed or not. Doesn't run the process. Or,
  • HasCmd() reveals if cmd is nil or not. Or,
  • HasIssues() reveals any issues before running cmd. Or,
  • CompiledErrorWrapper() to check the final error condition.

func (*CmdOnce) CompiledResult

func (it *CmdOnce) CompiledResult() *Result

CompiledResult

RunOnce and submits the compiled result structure.

func (*CmdOnce) CompiledTrimmedErrorLines

func (it *CmdOnce) CompiledTrimmedErrorLines() []string

CompiledTrimmedErrorLines returns lazy once result.

Developer may check:

  • IsSuccessfullyExecuted() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • HasAnyIssues() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • isAlreadyRan() reveals already executed or not. Doesn't run the process. Or,
  • HasCmd() reveals if cmd is nil or not. Or,
  • HasIssues() reveals any issues before running cmd. Or,
  • CompiledErrorWrapper() to check the final error condition.

func (*CmdOnce) CompiledTrimmedOutputLines

func (it *CmdOnce) CompiledTrimmedOutputLines() []string

CompiledTrimmedOutputLines returns lazy once result.

Developer may check:

  • IsSuccessfullyExecuted() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • HasAnyIssues() reveals if any issue after compile, thus runs the compile or RunOnce() first then returns bool. Or,
  • isAlreadyRan() reveals already executed or not. Doesn't run the process. Or,
  • HasCmd() reveals if cmd is nil or not. Or,
  • HasIssues() reveals any issues before running cmd. Or,
  • CompiledErrorWrapper() to check the final error condition.

func (*CmdOnce) Dispose added in v0.7.9

func (it *CmdOnce) Dispose()

func (*CmdOnce) DisposeWithoutErrorWrapper added in v0.8.9

func (it *CmdOnce) DisposeWithoutErrorWrapper()

func (*CmdOnce) DisposeWithoutResult added in v0.9.2

func (it *CmdOnce) DisposeWithoutResult()

func (*CmdOnce) DoubleQuoteWholeCommandLine

func (it *CmdOnce) DoubleQuoteWholeCommandLine() string

DoubleQuoteWholeCommandLine Process + Space + ArgumentsCompiledWithSpace

func (*CmdOnce) GetCommandLineDataDependingOnSecurity added in v0.5.8

func (it *CmdOnce) GetCommandLineDataDependingOnSecurity() string

func (*CmdOnce) GetFormattedKeyValueData

func (it *CmdOnce) GetFormattedKeyValueData(
	varName string,
	varValue string,
) string

GetFormattedKeyValueData "MY_VAR=some_value"

func (*CmdOnce) HasAnyIssues

func (it *CmdOnce) HasAnyIssues() bool

HasAnyIssues

executes run command and gets the compiled result and check if any compilation error Any issues include compile or cmd running error.

func (*CmdOnce) HasCmd

func (it *CmdOnce) HasCmd() bool

func (*CmdOnce) HasCompiledError

func (it *CmdOnce) HasCompiledError() bool

func (*CmdOnce) HasIssues

func (it *CmdOnce) HasIssues() bool

HasIssues reveals either cmd is nil or has any other cmd initialize error but it doesn't conclude running issues.

func (*CmdOnce) InitializeEnvVars added in v0.9.6

func (it *CmdOnce) InitializeEnvVars()

InitializeEnvVars

Warning must be set before run.

func (*CmdOnce) IsAlreadyRan

func (it *CmdOnce) IsAlreadyRan() bool

func (*CmdOnce) IsNull

func (it *CmdOnce) IsNull() bool

func (*CmdOnce) IsSuccessfullyExecuted

func (it *CmdOnce) IsSuccessfullyExecuted() bool

IsSuccessfullyExecuted Runs the execution and then returns the success result.

Reveals if any issue after compile, thus runs Compile() or RunOnce() first then returns bool.

func (*CmdOnce) NewArgs

func (it *CmdOnce) NewArgs(additionalArgs ...string) *CmdOnce

func (*CmdOnce) ProcessName

func (it *CmdOnce) ProcessName() string

func (*CmdOnce) Run

func (it *CmdOnce) Run() *Result

Run non lazy and runs as many times called.

Warning: Costly operation, run it wisely.

Under the hood, it creates the same cmdOnce and call it's RunOnce.

func (*CmdOnce) RunOnce

func (it *CmdOnce) RunOnce() *Result

RunOnce only runs once the process and returns the cached data many times.

func (*CmdOnce) RunOnceWithSuccessFlag

func (it *CmdOnce) RunOnceWithSuccessFlag() (cmdResult *Result, isSuccess bool)

RunOnceWithSuccessFlag Runs the process then returns the isSuccess flag

func (*CmdOnce) String

func (it *CmdOnce) String() string

String()

If cmd is present and HasIssues false then it will call RunOnce and get the output and returns it.

func (*CmdOnce) WholeCommandLine

func (it *CmdOnce) WholeCommandLine() string

WholeCommandLine Process + Space + ArgumentsCompiledWithSpace

type CmdOnceCollection added in v0.5.8

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

func BashScriptsLinesCmdOneCollection added in v0.5.9

func BashScriptsLinesCmdOneCollection(
	isTrimEmptyLines bool,
	scriptLines ...string,
) *CmdOnceCollection

func NewCmdOnceCollection added in v0.5.8

func NewCmdOnceCollection(capacity int) *CmdOnceCollection

func NewCmdOnceCollection2 added in v0.5.9

func NewCmdOnceCollection2() *CmdOnceCollection

func NewCmdOnceCollectionUsingLines added in v0.5.9

func NewCmdOnceCollectionUsingLines(
	scriptType scripttype.Variant,
	isTrimEmptyLines bool,
	scriptLines ...string,
) *CmdOnceCollection

func NewCmdOnceCollectionUsingLinesDirect added in v0.5.9

func NewCmdOnceCollectionUsingLinesDirect(
	scriptType scripttype.Variant,
	isTrimEmptyLines bool,
	scriptLines ...string,
) *CmdOnceCollection

func NewCmdOnceCollectionUsingLinesOfScripts added in v0.6.5

func NewCmdOnceCollectionUsingLinesOfScripts(
	scriptType scripttype.Variant,
	scriptLines ...string,
) *CmdOnceCollection

func NewCmdOnceCollectionUsingLinesPtr added in v0.5.9

func NewCmdOnceCollectionUsingLinesPtr(
	scriptType scripttype.Variant,
	isTrimEmptyLines bool,
	scriptLines *[]string,
) *CmdOnceCollection

func (*CmdOnceCollection) Add added in v0.5.8

func (it *CmdOnceCollection) Add(
	cmdOnce *CmdOnce,
) *CmdOnceCollection

func (*CmdOnceCollection) AddBashArgsDefault added in v0.9.2

func (it *CmdOnceCollection) AddBashArgsDefault(
	args ...string,
) *CmdOnceCollection

func (*CmdOnceCollection) AddBashChangeDirArgs added in v0.5.8

func (it *CmdOnceCollection) AddBashChangeDirArgs(
	changeDir string,
	args ...string,
) *CmdOnceCollection

func (*CmdOnceCollection) AddBashChangeDirScripts added in v0.5.8

func (it *CmdOnceCollection) AddBashChangeDirScripts(
	changeDir string,
	scripts ...string,
) *CmdOnceCollection

func (*CmdOnceCollection) AddBashEachScriptAsEachCmdOnce added in v0.5.9

func (it *CmdOnceCollection) AddBashEachScriptAsEachCmdOnce(
	scriptLines ...string,
) *CmdOnceCollection

func (*CmdOnceCollection) AddDefaultScript added in v0.5.8

func (it *CmdOnceCollection) AddDefaultScript(
	scriptType scripttype.Variant,
	scriptsLines ...string,
) *CmdOnceCollection

AddDefaultScript joins using SingleLineScriptsJoiner whereas args joins using space

func (*CmdOnceCollection) AddDefaultScriptArgs added in v0.5.8

func (it *CmdOnceCollection) AddDefaultScriptArgs(
	scriptType scripttype.Variant,
	args ...string,
) *CmdOnceCollection

AddDefaultScriptArgs args joins with space and whereas Scripts joins with SingleLineScriptsJoiner

func (*CmdOnceCollection) AddEachScriptAsEachCmdOnce added in v0.5.9

func (it *CmdOnceCollection) AddEachScriptAsEachCmdOnce(
	scriptType scripttype.Variant,
	scriptLines ...string,
) *CmdOnceCollection

func (*CmdOnceCollection) AddMany added in v0.5.8

func (it *CmdOnceCollection) AddMany(
	cmdOnceItems ...*CmdOnce,
) *CmdOnceCollection

func (*CmdOnceCollection) AsBasicSliceContractsBinder added in v0.5.8

func (it *CmdOnceCollection) AsBasicSliceContractsBinder() coreinterface.BasicSlicerContractsBinder

func (*CmdOnceCollection) AsBasicSlicerContractsBinder added in v0.5.8

func (it *CmdOnceCollection) AsBasicSlicerContractsBinder() coreinterface.BasicSlicerContractsBinder

func (*CmdOnceCollection) Clear added in v0.7.9

func (it *CmdOnceCollection) Clear() *CmdOnceCollection

func (*CmdOnceCollection) Clone added in v0.5.9

func (it *CmdOnceCollection) Clone() *CmdOnceCollection

func (*CmdOnceCollection) CommandsStrings added in v0.5.8

func (it *CmdOnceCollection) CommandsStrings() []string

func (*CmdOnceCollection) CompiledOneErrorWrapper added in v0.5.8

func (it *CmdOnceCollection) CompiledOneErrorWrapper() *errorwrapper.Wrapper

func (*CmdOnceCollection) Count added in v0.5.8

func (it *CmdOnceCollection) Count() int

func (*CmdOnceCollection) Dispose added in v0.7.9

func (it *CmdOnceCollection) Dispose()

func (*CmdOnceCollection) ErrorWrappers added in v0.5.8

func (it *CmdOnceCollection) ErrorWrappers() []*errorwrapper.Wrapper

func (*CmdOnceCollection) ExecuteAll added in v0.5.9

func (it *CmdOnceCollection) ExecuteAll() *errorwrapper.Wrapper

func (*CmdOnceCollection) ExecuteAllWithoutLazy added in v0.5.9

func (it *CmdOnceCollection) ExecuteAllWithoutLazy() *errorwrapper.Wrapper

func (*CmdOnceCollection) ExecuteAllWithoutLazyResults added in v0.5.9

func (it *CmdOnceCollection) ExecuteAllWithoutLazyResults() []*Result

func (*CmdOnceCollection) ExecuteUntilErr added in v0.5.9

func (it *CmdOnceCollection) ExecuteUntilErr() *errorwrapper.Wrapper

func (*CmdOnceCollection) FailedOutputStringsOnly added in v0.5.8

func (it *CmdOnceCollection) FailedOutputStringsOnly() []string

FailedOutputStringsOnly returns slice of strings output if cmd has failed only

func (*CmdOnceCollection) HasAnyIssuesRunning added in v0.5.8

func (it *CmdOnceCollection) HasAnyIssuesRunning() bool

func (*CmdOnceCollection) HasAnyItem added in v0.5.8

func (it *CmdOnceCollection) HasAnyItem() bool

func (*CmdOnceCollection) HasIndex added in v0.5.8

func (it *CmdOnceCollection) HasIndex(index int) bool

func (*CmdOnceCollection) IsAllSuccess added in v0.5.8

func (it *CmdOnceCollection) IsAllSuccess() bool

func (*CmdOnceCollection) IsEmpty added in v0.5.8

func (it *CmdOnceCollection) IsEmpty() bool

func (*CmdOnceCollection) Items added in v0.5.8

func (it *CmdOnceCollection) Items() []*CmdOnce

func (*CmdOnceCollection) LastIndex added in v0.5.8

func (it *CmdOnceCollection) LastIndex() int

func (*CmdOnceCollection) Length added in v0.5.8

func (it *CmdOnceCollection) Length() int

func (*CmdOnceCollection) OutputsStrings added in v0.5.8

func (it *CmdOnceCollection) OutputsStrings() []string

func (*CmdOnceCollection) Results added in v0.5.8

func (it *CmdOnceCollection) Results() []*Result

func (*CmdOnceCollection) String added in v0.5.8

func (it *CmdOnceCollection) String() string

func (*CmdOnceCollection) Strings added in v0.5.8

func (it *CmdOnceCollection) Strings() []string

func (*CmdOnceCollection) StringsProcessor added in v0.5.8

func (it *CmdOnceCollection) StringsProcessor(
	processor func(cmdOnce *CmdOnce) (processedLine string, isTake, isBreak bool),
) []string

func (*CmdOnceCollection) SuccessStringsOnly added in v0.5.8

func (it *CmdOnceCollection) SuccessStringsOnly() []string

SuccessStringsOnly returns slice of strings output if cmd has success only

type CurrentOsScriptBuilder added in v0.9.6

type CurrentOsScriptBuilder interface {
	CurrentOsTypes() []osmixtype.Variant
	CurrentOsTypesMap() map[osmixtype.Variant]bool
	BuildersMap() map[osmixtype.Variant]ScriptOnceBuilder
	ResultsMap() map[osmixtype.Variant]*Result
	CmdOnceMap() map[osmixtype.Variant]*CmdOnce
	OutputMap() map[osmixtype.Variant]string
	DetailedMap() map[osmixtype.Variant]string
	CmdMap() map[osmixtype.Variant]*exec.Cmd
	OutputLinesSimpleSliceMap() map[osmixtype.Variant]*corestr.SimpleSlice

	// HasAnyItem
	//
	// Only counts and checks available builders, O(N), expensive
	HasAnyItem() bool
	// IsEmpty
	//
	// Only counts and checks available builders, O(N), expensive
	IsEmpty() bool

	coreinterface.CombinedValidationChecker
	coreinterface.IsSuccessValidator
	errcoreinf.CompiledVoidLogger

	Length() int
	AvailableLength() int
}

type FilterScriptBuilderFunc added in v0.9.6

type FilterScriptBuilderFunc func(variant osmixtype.Variant, builder ScriptOnceBuilder) (isTake, isBreak bool)

type OsMixTypeScriptBuilder added in v0.9.6

type OsMixTypeScriptBuilder interface {
	TaskName() string
	SetTaskName(taskName string) OsMixTypeScriptBuilder

	AddNewBuilder(
		osMixType osmixtype.Variant,
		scriptType scripttype.Variant,
	) OsMixTypeScriptBuilder
	AddBuilder(
		osMixType osmixtype.Variant,
		builder ScriptOnceBuilder,
	) OsMixTypeScriptBuilder

	Description() string
	SetDescription(description string) OsMixTypeScriptBuilder

	Url() string
	SetUrl(url string) OsMixTypeScriptBuilder

	ExistingOsMixTypes() []osmixtype.Variant
	SetCurrentEnv(
		osMixTypes ...osmixtype.Variant,
	) *errorwrapper.Wrapper
	SetCurrentEnvToAll() OsMixTypeScriptBuilder
	SetCurrentEnvPlus(
		osMixType osmixtype.Variant,
		envValues ...corestr.KeyValuePair,
	) *errorwrapper.Wrapper
	SetCurrentEnvPlusIf(
		isCondition bool,
		osMixType osmixtype.Variant,
		envValues ...corestr.KeyValuePair,
	) *errorwrapper.Wrapper
	SetCurrentEnvPlusMapAll(envMap map[string]string) OsMixTypeScriptBuilder
	EnvVars(osMixType osmixtype.Variant) *corestr.KeyValueCollection
	HasAnyEnvVarsOnAll(osMixTypes ...osmixtype.Variant) bool
	IsCurrentEnvSetOnAll(osMixTypes ...osmixtype.Variant) bool

	AddProcessArgs(
		process string,
		args ...string,
	) OsMixTypeScriptBuilder

	AddProcessArgsBy(
		osMixType osmixtype.Variant,
		process string,
		args ...string,
	) OsMixTypeScriptBuilder
	AddArgsByIf(
		isAdd bool,
		osMixType osmixtype.Variant,
		args ...string,
	) OsMixTypeScriptBuilder
	AddProcessArgsByIf(
		isAdd bool,
		osMixType osmixtype.Variant,
		process string,
		args ...string,
	) OsMixTypeScriptBuilder
	AddArgsBy(
		osMixType osmixtype.Variant,
		args ...string,
	) OsMixTypeScriptBuilder
	AddArgs(args ...string) OsMixTypeScriptBuilder
	AddArgsIf(
		isAdd bool,
		args ...string,
	) OsMixTypeScriptBuilder

	Unix() ScriptOnceBuilder
	Windows() ScriptOnceBuilder
	Linux() ScriptOnceBuilder
	MacOs() ScriptOnceBuilder
	Ubuntu() ScriptOnceBuilder
	CentOs() ScriptOnceBuilder
	GetBy(
		osMixType osmixtype.Variant,
	) ScriptOnceBuilder

	// GetWithStat
	//
	//  isDefined : found and not null
	GetWithStat(
		osMixType osmixtype.Variant,
	) (scriptOnceBuilder ScriptOnceBuilder, isDefined bool)
	HasBuilder(
		mixType osmixtype.Variant,
	) bool

	// IsValidBuilder
	//
	//	represents that builder present
	//	and script lines present
	//	and script type is valid
	//
	//  return it != nil &&
	//		it.scriptType.IsValid() &&
	//		!it.HasError() &&
	//		it.scriptLines.HasAnyItem()
	IsValidBuilder(
		mixType osmixtype.Variant,
	) bool
	// IsInvalidBuilder
	//
	//  invert of IsValidBuilder
	IsInvalidBuilder(
		mixType osmixtype.Variant,
	) bool

	// IsAllBuildersValid
	//
	//  represents that all builder exist
	//  with lines and script type is valid
	IsAllBuildersValid(
		mixTypes ...osmixtype.Variant,
	) bool
	IsAnyInvalidBuilders(
		mixTypes ...osmixtype.Variant,
	) bool
	IsBuilderMissing(
		mixType osmixtype.Variant,
	) bool
	// IsBuilderMissingOrInvalid
	//
	//  Either builder not found or,
	//  builder has no script lines or
	//  script type is not valid
	IsBuilderMissingOrInvalid(
		mixType osmixtype.Variant,
	) bool
	HasBuilderScriptLines(
		mixType osmixtype.Variant,
	) bool
	GetBuilder(
		mixType osmixtype.Variant,
	) (scriptBuilder ScriptOnceBuilder, hasBuilder bool)
	HasAllBuilder(
		mixTypes ...osmixtype.Variant,
	) bool
	HasAnyBuilder(
		mixTypes ...osmixtype.Variant,
	) bool

	HasUnix() bool
	HasWindows() bool
	HasLinux() bool

	IsEmptyUnix() bool
	IsEmptyWindows() bool
	IsEmptyLinux() bool
	IsEmptyMacOs() bool

	IsEmptyBy(osMixType osmixtype.Variant) bool
	HasAnyItemBy(osMixType osmixtype.Variant) bool

	LoopInvokeFunc(processorFunc ScriptBuilderWithTypeProcessorFunc)

	Filter(
		filter FilterScriptBuilderFunc,
	) (resultMap map[osmixtype.Variant]ScriptOnceBuilder)

	FilterOsMixTypes(
		filter FilterScriptBuilderFunc,
	) (osMixTypes []osmixtype.Variant)
	GetBuildersMapByOsMixTypes(
		osMixTypes []osmixtype.Variant,
	) (resultMap map[osmixtype.Variant]ScriptOnceBuilder)
	UnixBuild() *CmdOnce
	WindowsBuild() *CmdOnce
	LinuxBuild() *CmdOnce
	MacOsBuild() *CmdOnce

	UnixBuildCmd() *exec.Cmd
	WindowsBuildCmd() *exec.Cmd
	LinuxBuildCmd() *exec.Cmd
	MacOsBuildCmd() *exec.Cmd

	List() []ScriptOnceBuilder
	ListMap() map[osmixtype.Variant]ScriptOnceBuilder
	IsNull() bool

	AvailableBuilders() []ScriptOnceBuilder
	BuildersMap() map[osmixtype.Variant]ScriptOnceBuilder
	AvailableBuildersMap() map[osmixtype.Variant]ScriptOnceBuilder
	ExecutionResultMap() map[osmixtype.Variant]*Result
	BuildMap() map[osmixtype.Variant]*CmdOnce

	BuildMapOnly(
		osMixes ...osmixtype.Variant,
	) map[osmixtype.Variant]*CmdOnce
	ResultMapOnly(
		osMixes ...osmixtype.Variant,
	) map[osmixtype.Variant]*Result
	BuildCmdMapOnly(
		osMixes ...osmixtype.Variant,
	) map[osmixtype.Variant]*exec.Cmd
	OutputMapOnly(
		osMixes ...osmixtype.Variant,
	) map[osmixtype.Variant]string
	OutputLinesSimpleSliceMapOnly(
		osMixes ...osmixtype.Variant,
	) map[osmixtype.Variant]*corestr.SimpleSlice
	DetailedOutputMapOnly(
		osMixes ...osmixtype.Variant,
	) map[osmixtype.Variant]string
	BuildersMapOnly(
		osMixes ...osmixtype.Variant,
	) map[osmixtype.Variant]ScriptOnceBuilder

	CurrentOsTypes() []osmixtype.Variant
	CurrentOsTypesMap() map[osmixtype.Variant]bool

	CurrentOsScriptBuilder() CurrentOsScriptBuilder

	CompiledErrorWrappersMapOnly(
		osMixes ...osmixtype.Variant,
	) (compiledMap map[osmixtype.Variant]*errorwrapper.Wrapper, hasAnyError bool)

	AllCompiledErrorWrappersMapOnly() (
		compiledMap map[osmixtype.Variant]*errorwrapper.Wrapper, hasAnyError bool,
	)

	BuildCmdMap() map[osmixtype.Variant]*exec.Cmd
	OutputMap() map[osmixtype.Variant]string

	OutputBytesMap() map[osmixtype.Variant][]byte
	CombinedOutputMap() map[osmixtype.Variant]coredata.BytesError
	AsyncExecutionResultMap() map[osmixtype.Variant]*Result

	StandardOutputCmd() OsMixTypeScriptBuilder
	AsyncStart(stdIn, stdOut, stderr *bytes.Buffer) (
		map[osmixtype.Variant]error, *sync.WaitGroup,
	)
	OutputMapMust() (resultMap map[osmixtype.Variant]string)
	TrimmedOutputMap() (resultMap map[osmixtype.Variant]string)
	OutputLinesMap() (resultMap map[osmixtype.Variant][]string)
	ErrorOutputMap() (resultMap map[osmixtype.Variant]string)
	TrimmedOutputLinesMap() (resultMap map[osmixtype.Variant][]string)
	BuildClearMap() (resultMap map[osmixtype.Variant]*CmdOnce)
	BuildDisposeMap() (resultMap map[osmixtype.Variant]*CmdOnce)
	// HasAnyItem
	//
	// Only counts and checks available builders, O(N), expensive
	HasAnyItem() bool
	// IsEmpty
	//
	// Only counts and checks available builders, O(N), expensive
	IsEmpty() bool

	coreinterface.CombinedValidationChecker
	coreinterface.IsSuccessValidator
	errcoreinf.CompiledVoidLogger

	Length() int
	// ValidLength
	//
	// Only counts and checks available builders, O(N), expensive
	ValidLength() int
	String() string
	StringsMap() (resultMap map[osmixtype.Variant][]string)
}

type Result

type Result struct {
	ExitError *exec.ExitError
	ExitCode  int
	// contains filtered or unexported fields
}

func NewResult

func NewResult(
	errorWrapper *errorwrapper.Wrapper,
	stdOut, stdErr *bytes.Buffer,
	exitError *exec.ExitError,
	hasCommandExecuted bool,
) *Result

func NewResultUsingBaseBuffer

func NewResultUsingBaseBuffer(
	errorWrapper *errorwrapper.Wrapper,
	baseBuffer *baseBufferStdOutError,
	exitError *exec.ExitError,
	hasCommandExecuted bool,
) *Result

func (*Result) AllErrorBytes added in v0.8.9

func (it *Result) AllErrorBytes() (errorBufferBytes []byte, compiledErrorWrapper *errorwrapper.Wrapper)

AllErrorBytes

errstr.Result Value represents std error buffer lines errstr.Result ErrorWrapper represents the Result.ErrorWrapper

func (*Result) AllErrorString added in v0.8.9

func (it *Result) AllErrorString() (errorBufferLine string, compiledErrorWrapper *errorwrapper.Wrapper)

AllErrorString

errstr.Result Value represents std error buffer lines errstr.Result ErrorWrapper represents the Result.ErrorWrapper

func (Result) CombinedBothErrorOutputLines added in v0.9.2

func (it Result) CombinedBothErrorOutputLines() []string

func (Result) CompiledErrorLines added in v0.9.2

func (it Result) CompiledErrorLines() []string

func (*Result) CompiledFullErrorWrapper added in v0.8.9

func (it *Result) CompiledFullErrorWrapper() *errorwrapper.Wrapper

CompiledFullErrorWrapper

Represents compiled error wrapper + std error line

(if baseBufferStdOutError has any error bytes)

func (Result) CompiledOutputLines added in v0.9.2

func (it Result) CompiledOutputLines() []string

func (Result) CompiledTrimmedErrorLines added in v0.9.2

func (it Result) CompiledTrimmedErrorLines() []string

func (Result) CompiledTrimmedErrorOutput added in v0.9.2

func (it Result) CompiledTrimmedErrorOutput() string

func (Result) CompiledTrimmedOutput added in v0.9.2

func (it Result) CompiledTrimmedOutput() string

func (Result) CompiledTrimmedOutputLines added in v0.9.2

func (it Result) CompiledTrimmedOutputLines() []string

func (*Result) DetailedOutput

func (it *Result) DetailedOutput() string

func (*Result) Dispose added in v0.7.9

func (it *Result) Dispose()

func (*Result) DisposeWithoutErrorWrapper added in v0.8.9

func (it *Result) DisposeWithoutErrorWrapper()

func (Result) ErrorBytes added in v0.9.2

func (it Result) ErrorBytes() []byte

func (Result) ErrorString added in v0.9.2

func (it Result) ErrorString() string

func (*Result) ErrorWrapper

func (it *Result) ErrorWrapper() *errorwrapper.Wrapper

func (*Result) ExitCodeByte added in v0.8.9

func (it *Result) ExitCodeByte() byte

func (*Result) HandleError added in v0.9.6

func (it *Result) HandleError()

func (*Result) HasAnyError added in v0.8.9

func (it *Result) HasAnyError() bool

func (*Result) HasCommandExecuted

func (it *Result) HasCommandExecuted() bool

func (*Result) HasError

func (it *Result) HasError() bool

func (Result) HasErrorBuffer added in v0.9.2

func (it Result) HasErrorBuffer() bool

func (Result) HasErrorBufferData added in v0.9.2

func (it Result) HasErrorBufferData() bool

func (Result) HasErrorContent added in v0.9.2

func (it Result) HasErrorContent() bool

HasErrorContent

Indicates error buffer has data. alias for HasErrorBufferData

func (*Result) HasExitError

func (it *Result) HasExitError() bool

func (*Result) HasNoError added in v0.8.9

func (it *Result) HasNoError() bool

func (Result) HasOutputBuffer added in v0.9.2

func (it Result) HasOutputBuffer() bool

func (Result) HasOutputBufferData added in v0.9.2

func (it Result) HasOutputBufferData() bool

func (Result) HasOutputContent added in v0.9.2

func (it Result) HasOutputContent() bool

HasOutputContent

Indicates output buffer has data. alias for HasOutputBufferData

func (*Result) HasValidExitCode added in v0.7.3

func (it *Result) HasValidExitCode() bool

func (*Result) IsEmptyError

func (it *Result) IsEmptyError() bool

func (Result) IsEmptyErrorBuffer added in v0.9.2

func (it Result) IsEmptyErrorBuffer() bool

IsEmptyErrorBuffer

Indicates error buffer has NO data.

func (Result) IsEmptyOutput added in v0.9.2

func (it Result) IsEmptyOutput() bool

IsEmptyOutput

Indicates output buffer has NO data.

func (*Result) IsExitCode

func (it *Result) IsExitCode(exitCode int) bool

func (*Result) IsExitCodeByte added in v0.7.3

func (it *Result) IsExitCodeByte(exitCode byte) bool

func (*Result) IsFailed added in v0.8.9

func (it *Result) IsFailed() bool

func (*Result) IsInvalid added in v0.8.9

func (it *Result) IsInvalid() bool

func (*Result) IsInvalidExitCode

func (it *Result) IsInvalidExitCode() bool

func (*Result) IsRunSuccessfully added in v0.7.3

func (it *Result) IsRunSuccessfully() bool

func (*Result) IsSuccess added in v0.8.9

func (it *Result) IsSuccess() bool

func (Result) OutputBytes added in v0.9.2

func (it Result) OutputBytes() []byte

func (Result) OutputString added in v0.9.2

func (it Result) OutputString() string

func (Result) SafeBytes added in v0.9.2

func (it Result) SafeBytes() []byte

SafeBytes

Alias for OutputBytes

func (Result) SafeErrorBytes added in v0.9.2

func (it Result) SafeErrorBytes() []byte

SafeErrorBytes

Alias for ErrorBytes

func (Result) String

func (it Result) String() string

func (Result) StringIf added in v0.9.0

func (it Result) StringIf(isErrorOnly bool) string

type ScriptBuilderFinalizer added in v0.9.6

type ScriptBuilderFinalizer interface {
	HasError() bool

	Result() *Result

	CompiledErrorWrapper() *errorwrapper.Wrapper
	ErrorWithTraces() error
	ErrorStringWithTraces() string
	// AsyncStart
	//
	//  Starts cmd in async manner,
	//  have to wait to be waited on
	//
	//  Check out exec.Cmd Start()
	AsyncStart() (*exec.Cmd, error)
	// AsyncStartErrorWrapper
	//
	//  Starts cmd in async manner,
	//  have to wait to be waited on
	//
	//  Check out exec.Cmd Start()
	AsyncStartErrorWrapper() (*exec.Cmd, *errorwrapper.Wrapper)

	CombinedOutput() ([]byte, error)
	CombinedOutputErrorWrapper() ([]byte, *errorwrapper.Wrapper)

	// Output
	//
	//  Gives compiled output
	Output() string

	// OutputMust
	//
	//  Gives compiled output,
	//  on error panics
	OutputMust() string

	// TrimmedOutput
	//
	//  Gives compiled output string without whitespace lines
	TrimmedOutput() string

	// String
	//
	//  Gives compiled output
	String() string

	// Strings
	//
	//  Gives compiled output lines
	Strings() []string
	ErrorOutput() string
	DetailedOutput() string
	OutputLines() []string
	OutputLinesSimpleSlice() *corestr.SimpleSlice
	TrimmedOutputLines() []string

	OutputBytes() []byte
	// StandardOutputCmd
	//
	//  refers to os standard output inputs binding
	//
	//  os.Stdin, os.Stdout, os.Stderr
	StandardOutputCmd() *exec.Cmd

	Build() *CmdOnce
	BuildClear() *CmdOnce
	BuildDispose() *CmdOnce
	BuildCmd() *exec.Cmd
	BuildCmdClear() *exec.Cmd

	NewBuilderWithArgs(args ...string) ScriptOnceBuilder
	Clone() ScriptOnceBuilder

	BuildCmdWithStdIn() (cmd *exec.Cmd, stdInWriter *bytes.Buffer)

	coreinterface.CombinedValidationChecker
	coreinterface.IsSuccessValidator
	errcoreinf.CompiledVoidLogger
}

type ScriptBuilderWithTypeProcessorFunc added in v0.9.6

type ScriptBuilderWithTypeProcessorFunc func(variant osmixtype.Variant, builder ScriptOnceBuilder)

type ScriptOnceBuilder added in v0.9.6

type ScriptOnceBuilder interface {
	ScriptBuilderFinalizer

	// CompiledProcessArgs
	//
	//  All ScriptLines will be compiled to
	//  args and script type will be output as process name
	CompiledProcessArgs() (
		processName string,
		args []string,
	)

	SetSecure() ScriptOnceBuilder
	SetPlainOutput() ScriptOnceBuilder
	EnableOutput() ScriptOnceBuilder
	DisableOutput() ScriptOnceBuilder

	SetScriptType(
		scriptType scripttype.Variant,
	) ScriptOnceBuilder

	SetScriptLines(
		scriptLines *corestr.SimpleSlice,
	) ScriptOnceBuilder
	SetStdIn(
		stdIn *bytes.Buffer,
	) ScriptOnceBuilder
	SetStdOut(
		stdOut *bytes.Buffer,
	) ScriptOnceBuilder
	SetStderr(
		stderr *bytes.Buffer,
	) ScriptOnceBuilder
	SetScript(
		scriptType scripttype.Variant,
	) ScriptOnceBuilder
	AllBuffers() (
		stdIn, stdOut, stderr *bytes.Buffer,
	)
	SetInputOutput(
		stdIn, stdOut, stderr *bytes.Buffer,
	) ScriptOnceBuilder
	AppendScriptLines(
		lines ...string,
	) ScriptOnceBuilder
	Args(
		args ...string,
	) ScriptOnceBuilder
	ArgsIf(
		isAdd bool,
		args ...string,
	) ScriptOnceBuilder
	ProcessArgs(
		process string,
		args ...string,
	) ScriptOnceBuilder
	Process(
		process string,
	) ScriptOnceBuilder
	ProcessArgsIf(
		isAdd bool,
		process string, args ...string,
	) ScriptOnceBuilder
	ProcessIf(
		isAdd bool,
		process string,
	) ScriptOnceBuilder

	ScriptLines() corestr.SimpleSlice
	Append(appendItems ...ScriptOnceBuilder) ScriptOnceBuilder
	// AppendCmd
	//
	//  Empty or has issues will be ignored.
	AppendCmd(appendItems ...*exec.Cmd) ScriptOnceBuilder
	// AppendCmdOnce
	//
	//  Empty or has issues will be ignored.
	AppendCmdOnce(appendItems ...*CmdOnce) ScriptOnceBuilder

	IsDefined() bool
	// HasPlainOutput
	//
	// returns true if not secure output and has output
	HasPlainOutput() bool
	// HasInsecureOutput
	//
	// returns true if not secure output
	HasInsecureOutput() bool
	HasStdIn() bool
	HasStdOut() bool
	HasStdErr() bool
	Length() int
	HasAnyItem() bool
	IsEmpty() bool
	IsNull() bool
	IsNotNull() bool
	IsAnyNull() bool
	IsValidWithoutItems() bool
	IsDisposed() bool
	IsFinalized() bool

	SetCurrentEnv() ScriptOnceBuilder
	SetCurrentEnvPlus(
		envValues ...corestr.KeyValuePair,
	) ScriptOnceBuilder
	SetCurrentEnvPlusIf(
		isCondition bool,
		envValues ...corestr.KeyValuePair,
	) ScriptOnceBuilder
	SetCurrentEnvPlusMap(envMap map[string]string) ScriptOnceBuilder
	EnvVars() *corestr.KeyValueCollection
	HasAnyEnvVars() bool
	IsCurrentEnvSet() bool

	Dispose()
	// Clear
	//
	//  clears commands stacks
	Clear()
}

type ScriptOnceBuilderContractsBinder added in v0.9.6

type ScriptOnceBuilderContractsBinder interface {
	ScriptOnceBuilder
	AsScriptOnceBuilderContractsBinder() ScriptOnceBuilderContractsBinder
}

type StdIn added in v0.8.0

type StdIn struct {
	OutBuf, ErrBuf *bytes.Buffer
}

func NewStdIn added in v0.8.0

func NewStdIn(outBufSize, errBuffSize int) *StdIn

func (*StdIn) HasStdErr added in v0.8.0

func (it *StdIn) HasStdErr() bool

func (*StdIn) HasStdOut added in v0.8.0

func (it *StdIn) HasStdOut() bool

func (*StdIn) StdErrString added in v0.8.0

func (it *StdIn) StdErrString() string

func (*StdIn) StdOutString added in v0.8.0

func (it *StdIn) StdOutString() string

Jump to

Keyboard shortcuts

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