diff --git a/internal/view/cmd/args.go b/internal/view/cmd/args.go index aaef7d61..2f95cb2a 100644 --- a/internal/view/cmd/args.go +++ b/internal/view/cmd/args.go @@ -31,19 +31,17 @@ func newArgs(p *Interpreter, aa []string) args { case strings.Index(a, fuzzyFlag) == 0: i++ - args[filterKey] = strings.TrimSpace(aa[i]) - continue + args[filterKey] = strings.ToLower(strings.TrimSpace(aa[i])) case strings.Index(a, filterFlag) == 0: - args[filterKey] = a[1:] + args[filterKey] = strings.ToLower(a[1:]) case strings.Contains(a, labelFlag): if ll := ToLabels(a); len(ll) != 0 { - args[labelKey] = a + args[labelKey] = strings.ToLower(a) } default: - a := strings.TrimSpace(aa[i]) switch { case p.IsContextCmd(): args[contextKey] = a @@ -53,12 +51,12 @@ func newArgs(p *Interpreter, aa []string) args { } case p.IsXrayCmd(): if _, ok := args[topicKey]; ok { - args[nsKey] = a + args[nsKey] = strings.ToLower(a) } else { - args[topicKey] = a + args[topicKey] = strings.ToLower(a) } default: - args[nsKey] = a + args[nsKey] = strings.ToLower(a) } } } diff --git a/internal/view/cmd/args_test.go b/internal/view/cmd/args_test.go index df4e4c31..8efe229e 100644 --- a/internal/view/cmd/args_test.go +++ b/internal/view/cmd/args_test.go @@ -79,6 +79,16 @@ func TestFlagsNew(t *testing.T) { aa: []string{"app=fred", "ns1", "-f", "blee", "/zorg", "@ctx1"}, ll: args{filterKey: "zorg", labelKey: "app=fred", nsKey: "ns1", contextKey: "ctx1"}, }, + "caps": { + i: NewInterpreter("po"), + aa: []string{"app=fred", "ns1", "-f", "blee", "/zorg", "@Dev"}, + ll: args{filterKey: "zorg", labelKey: "app=fred", nsKey: "ns1", contextKey: "Dev"}, + }, + "ctx": { + i: NewInterpreter("ctx"), + aa: []string{"Dev"}, + ll: args{contextKey: "Dev"}, + }, } for k := range uu { diff --git a/internal/view/cmd/interpreter.go b/internal/view/cmd/interpreter.go index 4b142e51..b95149c5 100644 --- a/internal/view/cmd/interpreter.go +++ b/internal/view/cmd/interpreter.go @@ -15,7 +15,7 @@ type Interpreter struct { func NewInterpreter(s string) *Interpreter { c := Interpreter{ - line: strings.ToLower(s), + line: s, args: make(args), } c.grok() @@ -28,7 +28,7 @@ func (c *Interpreter) grok() { if len(ff) == 0 { return } - c.cmd = ff[0] + c.cmd = strings.ToLower(ff[0]) c.args = newArgs(c, ff[1:]) } @@ -59,7 +59,7 @@ func (c *Interpreter) Amend(c1 *Interpreter) { } func (c *Interpreter) Reset(s string) *Interpreter { - c.line = strings.ToLower(s) + c.line = s c.grok() return c diff --git a/internal/view/cmd/interpreter_test.go b/internal/view/cmd/interpreter_test.go index bb78da78..cc5c9ca9 100644 --- a/internal/view/cmd/interpreter_test.go +++ b/internal/view/cmd/interpreter_test.go @@ -242,6 +242,11 @@ func TestDirCmd(t *testing.T) { "toast-nodir": { cmd: "dir", }, + "caps": { + cmd: "dir DirName", + ok: true, + dir: "DirName", + }, } for k := range uu { @@ -330,6 +335,11 @@ func TestContextCmd(t *testing.T) { "toast": { cmd: "ctxto ctx1", }, + "caps": { + cmd: "ctx Dev", + ok: true, + ctx: "Dev", + }, } for k := range uu {