cmd

package
v0.0.0-...-db53517 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MulanPSL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTimeOut = int64(10 * 60)
)
View Source
var LineSeparator string

Functions

func RemoveEmptyElm

func RemoveEmptyElm(arr []string) []string

RemoveEmptyElm 数组去除空白元素

Types

type CmdMgr

type CmdMgr struct {
}

func NewCmdMgr

func NewCmdMgr() *CmdMgr

func (*CmdMgr) BatchSyncExecute

func (mgr *CmdMgr) BatchSyncExecute(cmdList []string, options ...Option) error

func (*CmdMgr) SyncExecute

func (mgr *CmdMgr) SyncExecute(cmdStr string, options ...Option) (*CmdStatus, error)

func (*CmdMgr) SyncExecuteToJson

func (mgr *CmdMgr) SyncExecuteToJson(response interface{}, cmdStr string, options ...Option) (*CmdStatus, error)

type CmdStatus

type CmdStatus struct {
	Cmd         string   `json:"cmd"`
	PID         int      `json:"pid"`
	Complete    bool     `json:"complete"`                   // false if stopped or signaled
	Exit        int      `json:"exit"`                       // exit code of process
	Error       error    `json:"error" swaggertype:"string"` // Go error
	StartTs     int64    `json:"startTs"`                    // Unix ts (nanoseconds), zero if Cmd not started
	StopTs      int64    `json:"stopTs"`                     // Unix ts (nanoseconds), zero if Cmd not started or running
	Runtime     float64  `json:"runtime"`                    // seconds, zero if Cmd not started
	StdoutLines []string `json:"stdout_lines"`
	StderrLines []string `json:"stderr_lines"`
	Stderr      string   `json:"stderr"`
	Stdout      string   `json:"stdout"`
}

type Option

type Option func(opts *Options)

func WithTimeoutOption

func WithTimeoutOption(timeout int64) Option

type Options

type Options struct {
	Timeout int64
}

Jump to

Keyboard shortcuts

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