Categorygithub.com/cosiner/argv
modulepackage
0.1.0
Repository: https://github.com/cosiner/argv.git
Documentation: pkg.go.dev

# README

Argv

GoDoc Build Status Coverage Status Go Report Card

Argv is a library for Go to split command line string into arguments array.

Documentation

Documentation can be found at Godoc

Example

func TestArgv(t *testing.T) {
	args, err := argv.Argv([]rune(" ls   `echo /`   |  wc  -l "), argv.ParseEnv(os.Environ()), argv.Run)
	if err != nil {
	    t.Fatal(err)
	}
	expects := [][]string{
	    []string{"ls", "/"},
	    []string{"wc", "-l"},
	}
	if !reflect.DeepEqual(args, expects) {
	    t.Fatal(args)
	}
}

LICENSE

MIT.

# Functions

Argv split cmdline string as array of argument array by the '|' character.
No description provided by the author
NewParser create a cmdline string parser.
NewScanner create a scanner and init it's internal states.
No description provided by the author
Scan is a utility function help split input text as tokens.

# Constants

TokBackQuote is reverse quoted string.
TokEOF means the input end.
TokPipe is the '|' character.
TokSpace represent space character sequence.
TokString for string.
No description provided by the author
No description provided by the author

# Variables

ErrInvalidSyntax was reported if there is a syntax error in command line string.

# Structs

No description provided by the author
Scanner is a cmdline string scanner.
Token is generated by the scanner with a type and value.

# Type aliases

No description provided by the author
TokenType is the type of tokens recognized by the scanner.