Separate completion metadata from literal choices
This commit is contained in:
@@ -82,7 +82,7 @@ sys.stdout.write(os.environ['PROBE_REPLY'])
|
||||
t.Fatal(err)
|
||||
}
|
||||
reply := func(candidates string, directive spfcobra.ShellCompDirective) string {
|
||||
return fmt.Sprintf("%s:%d\n", candidates, directive)
|
||||
return fmt.Sprintf("%s\n%s:%d\n", completionPathPrefixMarker, candidates, directive)
|
||||
}
|
||||
pathReply := func(kind commandmeta.CompletionKind, prefix string) string {
|
||||
result, err := CompletionReply(commandmeta.CompletionResult{Kind: kind, Prefix: prefix})
|
||||
@@ -115,6 +115,7 @@ sys.stdout.write(os.environ['PROBE_REPLY'])
|
||||
{"short equals choice", "probe -c=bl", choiceReply("-c=", "blue"), []string{"__complete", "-c=bl"}, []string{"-c=blue"}},
|
||||
{"short choice with equals", "probe -cfoo=ba", choiceReply("-c", "foo=bar"), []string{"__complete", "-cfoo=ba"}, []string{"-cfoo=bar"}},
|
||||
{"short no suggestions", "probe -cnomatch", pathReply(commandmeta.CompletionChoices, "-c"), []string{"__complete", "-cnomatch"}, []string{"-cnomatch"}},
|
||||
{"literal active help", "probe _act", choiceReply("", "_activeHelp_ choice"), []string{"__complete", "_act"}, []string{"_activeHelp_ choice"}},
|
||||
{"literal prefix marker", "probe __commandkit_path_pre", choiceReply("", completionPathPrefixMarker+"-c"), []string{"__complete", "__commandkit_path_pre"}, []string{completionPathPrefixMarker + "-c"}},
|
||||
{"literal marker attached", "probe --config=__commandkit_path_pre", choiceReply("--config=", completionPathPrefixMarker+"-c"), []string{"__complete", "--config=__commandkit_path_pre"}, []string{"--config=" + completionPathPrefixMarker + "-c"}},
|
||||
{"option-looking separate value", "probe --format --tag=ch", choiceReply("", "--tag=chosen"), []string{"__complete", "--format", "--tag=ch"}, []string{"--format", "--tag=chosen"}},
|
||||
@@ -174,7 +175,7 @@ sys.stdout.write(os.environ['PROBE_REPLY'])
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("python3", "testdata/completion_terminal.py", shell, script, tc.line)
|
||||
cmd.Env = append(os.Environ(), "PATH="+dir+string(os.PathListSeparator)+os.Getenv("PATH"), "HOME="+dir, "TERM=xterm", "PROBE_DIR="+dir, "PROBE_LOG="+log, "PROBE_TAB_ONLY=1", "PROBE_REPLY=:4\n")
|
||||
cmd.Env = append(os.Environ(), "PATH="+dir+string(os.PathListSeparator)+os.Getenv("PATH"), "HOME="+dir, "TERM=xterm", "PROBE_DIR="+dir, "PROBE_LOG="+log, "PROBE_TAB_ONLY=1", "PROBE_REPLY="+reply("", spfcobra.ShellCompDirectiveNoFileComp))
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("tab-only completion: %v\n%s", err, out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user