cmd

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	And   = "&&" //与
	Or    = "||" //或
	Alone = ";"  //单独执行
)

Variables

Functions

func Exec

func Exec(command string, opts ...Options) error

func Execs

func Execs(commands []string, control ...string) error

func Print

func Print(c *color.Color, s string)

func Shell

func Shell(command string, opts ...Options) error

func Sudo

func Sudo(command string, opts ...Options) error

Types

type Buffer

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

func (*Buffer) Copy

func (b *Buffer) Copy(src io.Reader) (written int64, err error)

func (*Buffer) Len

func (b *Buffer) Len() int

func (*Buffer) Read

func (b *Buffer) Read(p []byte) (n int, err error)

func (*Buffer) ReadString

func (b *Buffer) ReadString(delim byte) (line string, err error)

func (*Buffer) String

func (b *Buffer) String() string

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

type Command

type Command struct {
	Cmd *exec.Cmd
	Ssh *ssh.Session
	In  io.Writer
	Out io.Reader
	Err io.Reader
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(command string, opts ...Options) (*Command, error)

func (*Command) Close

func (c *Command) Close() error

func (*Command) CombinedOutput

func (c *Command) CombinedOutput() (string, error)

func (*Command) Error

func (c *Command) Error(data []byte) (int, error)

func (*Command) ErrorAll

func (c *Command) ErrorAll() (string, error)

func (*Command) ErrorLine

func (c *Command) ErrorLine() (string, error)

func (*Command) Exited

func (c *Command) Exited() bool

func (*Command) Kill

func (c *Command) Kill() error

func (*Command) Output

func (c *Command) Output() (string, error)

func (*Command) Print

func (c *Command) Print()

func (*Command) PrintError

func (c *Command) PrintError()

func (*Command) Read

func (c *Command) Read(data []byte) (int, error)

func (*Command) ReadAll

func (c *Command) ReadAll() (string, error)

func (*Command) ReadLine

func (c *Command) ReadLine() (string, error)

func (*Command) Run

func (c *Command) Run() error

func (*Command) Start

func (c *Command) Start() error

func (*Command) Wait

func (c *Command) Wait() error

func (*Command) Write

func (c *Command) Write(data []byte) (int, error)

func (*Command) WriteLine

func (c *Command) WriteLine(command string) error

type Options

type Options struct {
	Stdin  io.ReadWriter
	Stdout io.ReadWriter
	Stderr io.ReadWriter
	Echo   bool
	Async  bool
	Passwd string
}

Jump to

Keyboard shortcuts

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