Slice support.
This commit is contained in:
+2
-9
@@ -1,7 +1,6 @@
|
||||
package kong
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -19,12 +18,6 @@ const (
|
||||
PositionalArgumentToken // <arg>
|
||||
)
|
||||
|
||||
type TokenAssertionError struct{ err error }
|
||||
|
||||
func (t TokenAssertionError) Error() string {
|
||||
return t.err.Error()
|
||||
}
|
||||
|
||||
type Token struct {
|
||||
Value string
|
||||
Type TokenType
|
||||
@@ -84,11 +77,11 @@ func (s *Scanner) Pop() Token {
|
||||
return arg
|
||||
}
|
||||
|
||||
// PopValue or panic with TokenAssertionError.
|
||||
// PopValue or panic with Error.
|
||||
func (s *Scanner) PopValue(context string) string {
|
||||
t := s.Pop()
|
||||
if !t.IsValue() {
|
||||
panic(TokenAssertionError{fmt.Errorf("expected %s value but got %s", context, t)})
|
||||
fail("expected %s value but got %s", context, t)
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user