This commit is contained in:
Alec Thomas
2018-05-18 13:38:07 +10:00
parent f929749094
commit c6776fe4b8
3 changed files with 10 additions and 4 deletions
+1 -3
View File
@@ -8,9 +8,7 @@ import (
"strings" "strings"
) )
type Error struct { type Error struct{ msg string }
msg string
}
func (e Error) Error() string { return e.msg } func (e Error) Error() string { return e.msg }
+1 -1
View File
@@ -50,7 +50,7 @@ func TestBranchingArgument(t *testing.T) {
Flag int `help:""` Flag int `help:""`
Delete struct{} `help:""` Delete struct{} `help:""`
Rename struct { Rename struct {
To string To string `help:""`
} `help:""` } `help:""`
} `arg:"" help:""` } `arg:"" help:""`
} `help:"Manage users."` } `help:"Manage users."`
+8
View File
@@ -57,6 +57,14 @@ func (t Token) IsValue() bool {
(t.Type == UntypedToken && !strings.HasPrefix(t.Value, "-")) (t.Type == UntypedToken && !strings.HasPrefix(t.Value, "-"))
} }
// Scanner is a stack-based scanner over command-line tokens.
//
// Initially all tokens are untyped. As the parser consumes tokens it assigns types, splits tokens, and pushes them back
// onto the stream.
//
// For example, the token "--foo=bar" will be split into the following by the parser:
//
// [{FlagToken, "foo"}, {FlagValueToken, "bar"}]
type Scanner struct { type Scanner struct {
args []Token args []Token
} }