command

package
v0.0.0-...-0adad2b Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderEnvironmentSettingScript

func RenderEnvironmentSettingScript(vars map[string]string, aliases map[string]string) string

Types

type Command

type Command struct {
	Command []string            `yaml:"command,omitempty,flow" json:"command,omitempty,flow"`
	Script  string              `yaml:"script,omitempty" json:"script,omitempty"`
	OS      map[string]*Command `yaml:"os,omitempty" json:"os,omitempty"`
	// List of tools required for this command to succeed.
	Tools []string `yaml:"tools,omitempty" json:"tools,omitempty"`
	// contains filtered or unexported fields
}

func (*Command) Execute

func (d *Command) Execute(ctx ExecutionContext, opts ...CommandOpts) (string, error)

Execute executes the ShellExe, and treats the Value field as a script.

func (Command) MarshalYAML

func (d Command) MarshalYAML() (interface{}, error)

func (*Command) String

func (d *Command) String() string

func (*Command) UnmarshalYAML

func (d *Command) UnmarshalYAML(unmarshal func(interface{}) error) error

type CommandOpts

type CommandOpts struct {
	// If true, echo output to stdout while running.
	StreamOutput bool
	// If true, execute even if --dry-run was passed.
	IgnoreDryRun bool
}

type CommandValue

type CommandValue struct {
	Comment              string `yaml:"comment,omitempty" json:"comment,omitempty"`
	Value                string `yaml:"value" json:"value"`
	Command              `yaml:"-" json:"-"`
	OS                   map[string]*CommandValue `yaml:"os,omitempty" json:"os,omitempty"`
	WorkspaceCommand     string                   `yaml:"workspaceCommand,omitempty"`
	WorkspaceCommandHint string                   `yaml:"workspaceCommandHint,omitempty"`
	Disabled             bool                     `yaml:"disabled"`
	// contains filtered or unexported fields
}

func (*CommandValue) GetValue

func (c *CommandValue) GetValue() string

func (*CommandValue) MarshalYAML

func (c *CommandValue) MarshalYAML() (interface{}, error)

func (*CommandValue) Resolve

func (c *CommandValue) Resolve(ctx ExecutionContext) (string, error)

Resolve sets the Value field by executing Script, Command, or an entry under OS. If resolve has been called before, the value from that resolve is returned.

func (*CommandValue) String

func (c *CommandValue) String() string

func (*CommandValue) UnmarshalYAML

func (c *CommandValue) UnmarshalYAML(node *yaml.Node) error

type DynamicValueOpts

type DynamicValueOpts struct {
	DiscardValue bool
	StreamOutput bool
}

type ShellExe

type ShellExe struct {
	// Exe is the executable to invoke.
	Exe *string
	// Args is the arguments to be passed to the exe.
	Args []string
	Env  []string
	// ShellExe is the exe with its args as a single string, as you would type it on the CLI.
	Command *string
	Dir     *string
	// contains filtered or unexported fields
}

func GetCommandForScript

func GetCommandForScript(file string) *ShellExe

func NewShellExe

func NewShellExe(exe string, args ...string) *ShellExe

func NewShellExeFromSlice

func NewShellExeFromSlice(args ...string) *ShellExe

func (*ShellExe) GetCmd

func (c *ShellExe) GetCmd() *exec.Cmd

func (*ShellExe) IncludeEnv

func (c *ShellExe) IncludeEnv(env map[string]string) *ShellExe

func (*ShellExe) MustOut

func (c *ShellExe) MustOut() string

func (*ShellExe) MustRun

func (c *ShellExe) MustRun()

MustRun runs the command and kills this process if the command returns an error.

func (*ShellExe) RunE

func (c *ShellExe) RunE() error

RunE runs the command and returns the error only. Input and output for current process are attached to the command process.

func (*ShellExe) RunOut

func (c *ShellExe) RunOut() (string, error)

RunOut runs the command and returns the output or an error.

func (*ShellExe) RunOutLog

func (c *ShellExe) RunOutLog() (string, error)

RunOutLog runs the command and returns all output as a string.

func (*ShellExe) String

func (c *ShellExe) String() string

func (*ShellExe) Sudo

func (c *ShellExe) Sudo(enabled bool) *ShellExe

func (*ShellExe) WithArgs

func (c *ShellExe) WithArgs(args ...string) *ShellExe

func (*ShellExe) WithCommand

func (c *ShellExe) WithCommand(cmd string) *ShellExe

func (*ShellExe) WithContext

func (c *ShellExe) WithContext(ctx context.Context) *ShellExe

func (*ShellExe) WithDir

func (c *ShellExe) WithDir(dir string) *ShellExe

func (*ShellExe) WithEnvValue

func (c *ShellExe) WithEnvValue(key, value string) *ShellExe

func (*ShellExe) WithExe

func (c *ShellExe) WithExe(exe string) *ShellExe

Jump to

Keyboard shortcuts

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