Documentation
¶
Overview ¶
Package cmdline provide quick build and parse cmd line string.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LineBuilder ¶
LineBuilder build command line string. codes refer from strings.Builder
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 "this is 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 (*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
func (*LineParser) WithParseEnv ¶
func (p *LineParser) WithParseEnv() *LineParser
WithParseEnv with parse ENV var
Click to show internal directories.
Click to hide internal directories.