Documentation ¶
Index ¶
- Variables
- type Argument
- type Arguments
- func (a Arguments) Append(b *Arguments) Arguments
- func (a Arguments) AppendString(s string) (Arguments, bool)
- func (a *Arguments) Current() (Argument, bool)
- func (a *Arguments) Len() int
- func (a *Arguments) Next() (Argument, bool)
- func (a *Arguments) Peek() (Argument, bool)
- func (a *Arguments) PeekBy(offset int) (Argument, bool)
- func (a *Arguments) Previous() (Argument, bool)
- func (a *Arguments) Range(start, end int) (Arguments, bool)
- func (a *Arguments) Raw(index int) (string, bool)
- func (a *Arguments) RawBy(offset int) (string, bool)
- func (a *Arguments) RawRange(start, end int) (string, bool)
- func (a *Arguments) Reset()
- func (a *Arguments) Seek(index int) bool
- func (a *Arguments) SeekBy(offset int) bool
- func (a Arguments) Strings() []string
Constants ¶
This section is empty.
Variables ¶
var QuotePairs = map[string]endQuote{
"'": "'",
"\"": "\"",
"\u201C\u201D\u201F\u201E": "\u201C\u201D\u201F",
"\u2018\u2019\u201B\u201A": "\u2018\u2019\u201B",
"\u00AB\u300A": "\u00BB\u300B",
"\u00BB\u300B": "\u00AB\u300A",
"\u2039\u3008": "\u203A\u3009",
"\u203A\u3009": "\u2039\u3008",
"\u300C\u300E": "\u300D\u300F",
}
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct {
// argument start and end positions
// be aware that this is the rune positions, not the byte positions
Start, End int
Content string
// if the argument was escaped via being prefixed with \
Escaped bool
Quoted bool
}
Argument is a single argument
type Arguments ¶
type Arguments struct { Cursor int // Cursor is the current position in the list of arguments Original string Arguments []Argument }
Arguments represents a list of arguments
func Parse ¶
Parse is a function that parses the given string into a list of arguments using the following syntax. - Spaces are used as delimiters to separate arguments.
- Duplicate spaces are ignored.
- Quotes are used to create a single argument ignoring spaces.
- (see `quotePairs` for list of supported quote types)
- `\` is used to escape quotes and spaces or other escapes. in addition, an escape may be used at the beginning of an argument to mark it as escaped.
func (Arguments) AppendString ¶
AppendString parses a string and appends it to the argument list returning the combined list
func (*Arguments) PeekBy ¶
PeekBy returns the argument at the given index relative to the current cursor
func (*Arguments) Range ¶
Range returns a copy of a containing only the arguments between the start and end positions
func (*Arguments) Raw ¶
Raw returns the original string between the start and end positions of an argument
func (*Arguments) RawBy ¶
RawBy returns the raw string of an argument at the given index relative to the current cursor
func (*Arguments) Seek ¶
Seek moves the cursor to the given index if it returns false it means it cannot seek to that position