nicer signature for PredictSet
This commit is contained in:
parent
87dada1ec4
commit
5dbf53eec0
|
@ -25,7 +25,7 @@ func TestCompleter_Complete(t *testing.T) {
|
|||
"sub2": {
|
||||
Flags: map[string]Predicate{
|
||||
"-flag2": PredictNothing,
|
||||
"-flag3": PredictNothing,
|
||||
"-flag3": PredictSet("opt1", "opt2", "opt12"),
|
||||
},
|
||||
Args: PredictDirs("./tests/").Or(PredictFiles("./tests/*.md")),
|
||||
},
|
||||
|
@ -160,6 +160,18 @@ func TestCompleter_Complete(t *testing.T) {
|
|||
args: "-o ./complete.go ",
|
||||
want: allGlobals,
|
||||
},
|
||||
{
|
||||
args: "-o sub2 -flag3 ",
|
||||
want: []string{"opt1", "opt2", "opt12"},
|
||||
},
|
||||
{
|
||||
args: "-o sub2 -flag3 opt1",
|
||||
want: []string{"opt1", "opt12"},
|
||||
},
|
||||
{
|
||||
args: "-o sub2 -flag3 opt",
|
||||
want: []string{"opt1", "opt2", "opt12"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
@ -58,7 +58,7 @@ func main() {
|
|||
"-benchtime": complete.PredictAnything,
|
||||
"-count": complete.PredictAnything,
|
||||
"-cover": complete.PredictNothing,
|
||||
"-covermode": complete.PredictSet([]string{"set", "count", "atomic"}),
|
||||
"-covermode": complete.PredictSet("set", "count", "atomic"),
|
||||
"-coverpkg": complete.PredictDirs("./"),
|
||||
"-cpu": complete.PredictAnything,
|
||||
"-run": predictTest("test"),
|
||||
|
|
|
@ -37,7 +37,7 @@ var (
|
|||
PredictAnything = Predicate{}
|
||||
)
|
||||
|
||||
func PredictSet(options []string) Predicate {
|
||||
func PredictSet(options ...string) Predicate {
|
||||
return Predicate{
|
||||
Predictor: func() []Option {
|
||||
ret := make([]Option, len(options))
|
||||
|
|
Loading…
Reference in New Issue