New method to get remaining arguments on a line

This commit is contained in:
Matthew Holt 2015-03-16 11:23:17 -06:00
parent 3858e31942
commit af56c5033c
2 changed files with 19 additions and 0 deletions

View file

@ -145,3 +145,21 @@ func (d *dispenser) Args(targets ...*string) bool {
}
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
}

View file

@ -23,6 +23,7 @@ type (
NextBlock() bool
Val() string
Args(...*string) bool
RemainingArgs() []string
ArgErr() error
Err(string) error
Startup(func() error)