Commit af56c503 authored by Matthew Holt's avatar Matthew Holt

New method to get remaining arguments on a line

parent 3858e319
...@@ -145,3 +145,21 @@ func (d *dispenser) Args(targets ...*string) bool { ...@@ -145,3 +145,21 @@ func (d *dispenser) Args(targets ...*string) bool {
} }
return enough return enough
} }
// RemainingArgs is a convenience function that loads any more arguments
// (tokens on the same line) into a slice and returns them. Open curly
// brace tokens indicate the end of arguments (the curly brace is not
// included).
func (d *dispenser) RemainingArgs() []string {
var args []string
for d.NextArg() {
if d.Val() == "{" {
d.cursor--
break
}
args = append(args, d.Val())
}
return args
}
...@@ -23,6 +23,7 @@ type ( ...@@ -23,6 +23,7 @@ type (
NextBlock() bool NextBlock() bool
Val() string Val() string
Args(...*string) bool Args(...*string) bool
RemainingArgs() []string
ArgErr() error ArgErr() error
Err(string) error Err(string) error
Startup(func() error) Startup(func() error)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment