cmd

package
v0.0.0-...-e49fa62 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIllegal

func CheckIllegal(args ...string) bool

func ExecCommandWithOptionalSudo

func ExecCommandWithOptionalSudo(name string, args ...string) *exec.Cmd

func RunDockerExec

func RunDockerExec(timeout time.Duration, containerName string, args ...string) error

func RunDockerExecWithStdout

func RunDockerExecWithStdout(timeout time.Duration, containerName string, args ...string) (string, error)

func SudoHandleCmd

func SudoHandleCmd() string

func Which

func Which(name string) bool

func WrapWithOptionalSudo

func WrapWithOptionalSudo(name string, args ...string) (string, []string)

func WriteFileWithOptionalSudo

func WriteFileWithOptionalSudo(name string, data []byte, perm os.FileMode) error

Types

type CommandHelper

type CommandHelper struct {
	IgnoreExist1 bool
	// contains filtered or unexported fields
}

func NewCommandMgr

func NewCommandMgr(opts ...Option) *CommandHelper

func (*CommandHelper) Run

func (c *CommandHelper) Run(name string, arg ...string) error

func (*CommandHelper) RunPipe

func (c *CommandHelper) RunPipe(commands ...PipeCommand) (string, error)

func (*CommandHelper) RunPipeToFile

func (c *CommandHelper) RunPipeToFile(outputFile string, commands ...PipeCommand) (string, error)

func (*CommandHelper) RunWithOptionalSudo

func (c *CommandHelper) RunWithOptionalSudo(name string, arg ...string) error

func (*CommandHelper) RunWithOptionalSudoAndStdout

func (c *CommandHelper) RunWithOptionalSudoAndStdout(name string, arg ...string) (string, error)

func (*CommandHelper) RunWithStdout

func (c *CommandHelper) RunWithStdout(name string, arg ...string) (string, error)

type CustomWriter

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

func (*CustomWriter) Flush

func (cw *CustomWriter) Flush()

func (*CustomWriter) Write

func (cw *CustomWriter) Write(p []byte) (n int, err error)

type Option

type Option func(*CommandHelper)

func WithContext

func WithContext(ctx context.Context) Option

func WithEnv

func WithEnv(env ...string) Option

func WithIgnoreExist1

func WithIgnoreExist1() Option

func WithLogger

func WithLogger(logger *log.Logger) Option

func WithOutputFile

func WithOutputFile(outputFile string) Option

func WithScriptPath

func WithScriptPath(scriptPath string) Option

func WithStdin

func WithStdin(stdin io.Reader) Option

func WithTask

func WithTask(taskItem task.Task) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithWorkDir

func WithWorkDir(workDir string) Option

type PipeCommand

type PipeCommand struct {
	Name  string
	Args  []string
	Env   []string
	Dir   string
	Stdin io.Reader
}

Jump to

Keyboard shortcuts

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