open-nomad/vendor/github.com/posener/complete/predict_set.go
Alex Dadgar 810ab68f94 Add command autocompletion.
This PR adds command autocompletion to the CLI.
2017-07-17 15:00:40 -07:00

20 lines
411 B
Go

package complete
import "github.com/posener/complete/match"
// PredictSet expects specific set of terms, given in the options argument.
func PredictSet(options ...string) Predictor {
return predictSet(options)
}
type predictSet []string
func (p predictSet) Predict(a Args) (prediction []string) {
for _, m := range p {
if match.Prefix(m, a.Last) {
prediction = append(prediction, m)
}
}
return
}