command

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	internal.Shared
	Powershell struct {
		PSFlags string
		Enabled bool
	}
	Cmd struct {
		CmdFlags      string
		RunWithoutCmd bool
		HideCmdWindow bool
	}
}

func InitCmd added in v1.3.0

func InitCmd(input string) Cmd

Initializes a new instance of the command, already setting the command to run

func InitCmdf added in v1.6.0

func InitCmdf(input string, args ...any) Cmd

func (Cmd) CombinedOut added in v1.3.0

func (sh Cmd) CombinedOut() (string, error)

Execute the command with all parameters already set, something like "exec.Command([formatted command]).CombinedOutput()" and return its error and string output, as well as executing with output to stdin,stdout and stderr.

func (*Cmd) CustomCmdFlags added in v1.3.0

func (sh *Cmd) CustomCmdFlags(flags string)

It sets the customized cmd flags, its syntax when executed would be something like this "cmd.exe [flags] /c command".

func (*Cmd) CustomCmdFlagsf added in v1.6.0

func (sh *Cmd) CustomCmdFlagsf(flags string, args ...any)

func (*Cmd) CustomPSFlags added in v1.3.0

func (sh *Cmd) CustomPSFlags(flags string)

It sets the customized powershell flags, its syntax when executed would be something like this "powershell.exe [flags] /c command".

func (*Cmd) CustomPSFlagsf added in v1.6.0

func (sh *Cmd) CustomPSFlagsf(flags string, args ...any)

func (*Cmd) CustomStd added in v1.3.0

func (sh *Cmd) CustomStd(Stdin, Stdout, Stderr bool)

Set custom Stdin,Stdout,Stderr in one function

func (Cmd) GetExec added in v1.3.1

func (sh Cmd) GetExec() *exec.Cmd

Returns the exec.Cmd structure with all parameters already configured

func (*Cmd) HideCmdWindow added in v1.3.0

func (sh *Cmd) HideCmdWindow(set bool)

Hides the cmd/powershell window that appears when executing a command in go.

func (Cmd) Out added in v1.3.0

func (sh Cmd) Out() (string, error)

Execute the command with all the parameters already set, something like "exec.Command([formatted command]).Output()" and return its string and error output

func (Cmd) Run added in v1.3.0

func (sh Cmd) Run() error

Execute the command with all the parameters already set, something like "exec.Command([formatted command]).Run()" and return its error output

func (*Cmd) RunWithPS added in v1.3.0

func (sh *Cmd) RunWithPS(set bool)

Run the command using "powershell.exe [parameters] /c command" instead of "cmd.exe [parameters] /c command"

func (*Cmd) RunWithoutCmd added in v1.3.0

func (sh *Cmd) RunWithoutCmd(set bool)

Execute the command directly, it is useful if you want to execute a binary, this mode does not have access to the path so you will have to put the full path of the binary or use something relative to execute it.

func (Cmd) SetAndCombinedOut added in v1.3.0

func (sh Cmd) SetAndCombinedOut(command string) (string, error)

It is the same as cmd := command.Cmd("<command>"); cmd.CombinedOut() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.

func (Cmd) SetAndCombinedOutf added in v1.6.0

func (sh Cmd) SetAndCombinedOutf(command string, args ...any) (string, error)

func (Cmd) SetAndOut added in v1.3.0

func (sh Cmd) SetAndOut(command string) (string, error)

It is the same as cmd := command.Cmd("<command>"); cmd.Out() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.

func (Cmd) SetAndOutf added in v1.6.0

func (sh Cmd) SetAndOutf(command string, args ...any) (string, error)

func (Cmd) SetAndRun added in v1.3.0

func (sh Cmd) SetAndRun(command string) error

It is the same as cmd := command.Cmd("<command>"); cmd.Run() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.

func (Cmd) SetAndRunf added in v1.6.0

func (sh Cmd) SetAndRunf(command string, args ...any) error

func (Cmd) SetAndStart added in v1.3.0

func (sh Cmd) SetAndStart(command string) error

It is the same as cmd := command.Cmd("<command>"); cmd.Start() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.

func (Cmd) SetAndStartf added in v1.6.0

func (sh Cmd) SetAndStartf(command string, args ...any) error

func (Cmd) Start added in v1.3.0

func (sh Cmd) Start() error

Execute the command with all the parameters already set, something like "exec.Command([formatted command]).Start()" and return its error output

func (*Cmd) Stderr added in v1.3.0

func (sh *Cmd) Stderr(set bool)

Set the individual Stderr

func (*Cmd) Stdin added in v1.3.0

func (sh *Cmd) Stdin(set bool)

Set the individual Stdin

func (*Cmd) Stdout added in v1.3.0

func (sh *Cmd) Stdout(set bool)

Set the individual Stdout

Jump to

Keyboard shortcuts

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