diff --git a/kong.go b/kong.go index 5c06d55..6fdfa47 100644 --- a/kong.go +++ b/kong.go @@ -8,9 +8,7 @@ import ( "strings" ) -type Error struct { - msg string -} +type Error struct{ msg string } func (e Error) Error() string { return e.msg } diff --git a/kong_test.go b/kong_test.go index 10e4894..9abbe54 100644 --- a/kong_test.go +++ b/kong_test.go @@ -50,7 +50,7 @@ func TestBranchingArgument(t *testing.T) { Flag int `help:""` Delete struct{} `help:""` Rename struct { - To string + To string `help:""` } `help:""` } `arg:"" help:""` } `help:"Manage users."` diff --git a/scanner.go b/scanner.go index e653988..08e7476 100644 --- a/scanner.go +++ b/scanner.go @@ -57,6 +57,14 @@ func (t Token) IsValue() bool { (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 { args []Token }