You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an Enums() flag, I noticed that it doesn't tab complete like an Enum() does. This was unexpected since the only difference is that an Enums allows multiple values from the set to be provided
Steps to reproduce
Save as main.go
package main
import (
"github.com/alecthomas/kingpin/v2"
)
var (
noComplete=kingpin.Flag("does-not-complete", "this flag does not tab complete").Enums("foo", "bar")
complete=kingpin.Flag("completes", "this flag will tab complete").Enum("foo", "bar")
)
funcmain() {
kingpin.Parse()
}
Then:
go mod init test-complete
go mod tidy
go build -o test-complete main.go
# use --completion-script-zsh if you're using zsheval"$(./test-complete --completion-script-bash)"# "foo" and "bar" won't show up as options
test-complete --does-not-complete <TAB># "foo" and "bar" show up as options
test-complete --completes <TAB>
bar foo
Workaround
Use HintOptions("foo", "bar") or HintAction(customFunc) when using an Enums type:
nowCompletes = kingpin.Flag("does-not-complete", "this flag does not tab complete").HintOptions("foo", "bar").Enums("foo", "bar")
This works fine, but seems wholly unnecessary to repeat the values twice and means Enums still doesn't behave the way it is expected to.
The text was updated successfully, but these errors were encountered:
stroopc-stripe
changed the title
Enums flag type doesn't tab complete
Enums() type doesn't tab complete
Jan 11, 2024
When using an
Enums()
flag, I noticed that it doesn't tab complete like anEnum()
does. This was unexpected since the only difference is that anEnums
allows multiple values from the set to be providedSteps to reproduce
Save as
main.go
Then:
Workaround
Use
HintOptions("foo", "bar")
orHintAction(customFunc)
when using anEnums
type:This works fine, but seems wholly unnecessary to repeat the values twice and means
Enums
still doesn't behave the way it is expected to.The text was updated successfully, but these errors were encountered: