cmdline

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LineBuild

func LineBuild(binFile string, args []string) string

LineBuild build command line string by given args.

func ParseLine

func ParseLine(line string) []string

ParseLine input command line text. alias of the StringToOSArgs()

Types

type LineBuilder

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

LineBuilder build command line string. codes refer from strings.Builder

func NewBuilder

func NewBuilder(binFile string, args ...string) *LineBuilder

NewBuilder create

func (*LineBuilder) AddArg

func (b *LineBuilder) AddArg(arg string)

AddArg to builder

func (*LineBuilder) AddArgs

func (b *LineBuilder) AddArgs(args ...string)

AddArgs to builder

func (*LineBuilder) AddArray

func (b *LineBuilder) AddArray(args []string)

AddArray to builder

func (*LineBuilder) Len

func (b *LineBuilder) Len() int

Len of the builder

func (*LineBuilder) Reset

func (b *LineBuilder) Reset()

Reset builder

func (*LineBuilder) String

func (b *LineBuilder) String() string

String to command line string

func (*LineBuilder) WriteString

func (b *LineBuilder) WriteString(a string) (int, error)

WriteString arg string to the builder, will auto quote special string. refer strconv.Quote()

type LineParser

type LineParser struct {

	// Line the full input command line text
	// eg `kite top sub -a "the a message" --foo val1 --bar "val 2"`
	Line string
	// ParseEnv parse ENV var on the line.
	ParseEnv bool
	// contains filtered or unexported fields
}

LineParser struct parse input command line to []string, such as cli os.Args

func NewParser

func NewParser(line string) *LineParser

NewParser create

func (*LineParser) AlsoEnvParse

func (p *LineParser) AlsoEnvParse() []string

AlsoEnvParse input command line text to os.Args, will parse ENV var

func (*LineParser) BinAndArgs

func (p *LineParser) BinAndArgs() (bin string, args []string)

BinAndArgs get binName and args

func (*LineParser) NewExecCmd

func (p *LineParser) NewExecCmd() *exec.Cmd

NewExecCmd quick create exec.Cmd by cmdline string

func (*LineParser) Parse

func (p *LineParser) Parse() []string

Parse input command line text to os.Args

Jump to

Keyboard shortcuts

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