Implement flag "resolvers". (#24)
* Propagate errors. * Use junit test output. * Expand role of DecodeContext to include Scanner. * Inject resolved flags as Path elements in the Context. This allows all existing logic to apply seamlessly: hooks, required flags, etc. * Clarify that hooks can be called multiple times.
This commit is contained in:
committed by
Gerald Kaszuba
parent
73064a687f
commit
e9d88d6528
+8
-3
@@ -7,8 +7,10 @@ import (
|
||||
|
||||
//go:generate stringer -type=TokenType
|
||||
|
||||
// TokenType is the type of a token.
|
||||
type TokenType int
|
||||
|
||||
// Token types.
|
||||
const (
|
||||
UntypedToken TokenType = iota
|
||||
EOLToken
|
||||
@@ -128,14 +130,17 @@ func (s *Scanner) Peek() Token {
|
||||
return s.args[0]
|
||||
}
|
||||
|
||||
func (s *Scanner) Push(arg string) {
|
||||
func (s *Scanner) Push(arg string) *Scanner {
|
||||
s.PushToken(Token{Value: arg})
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Scanner) PushTyped(arg string, typ TokenType) {
|
||||
func (s *Scanner) PushTyped(arg string, typ TokenType) *Scanner {
|
||||
s.PushToken(Token{Value: arg, Type: typ})
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Scanner) PushToken(token Token) {
|
||||
func (s *Scanner) PushToken(token Token) *Scanner {
|
||||
s.args = append([]Token{token}, s.args...)
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user