mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-03 17:43:49 +03:00
New method to get remaining arguments on a line
This commit is contained in:
parent
3858e31942
commit
af56c5033c
2 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ type (
|
|||
NextBlock() bool
|
||||
Val() string
|
||||
Args(...*string) bool
|
||||
RemainingArgs() []string
|
||||
ArgErr() error
|
||||
Err(string) error
|
||||
Startup(func() error)
|
||||
|
|
Loading…
Reference in a new issue