diff options
| author | Eyal Posener <[email protected]> | 2017-05-11 22:00:21 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2017-05-11 22:02:05 +0300 |
| commit | 200b1b5b690cf8b9202c52b6d85e52d99a3f0b4d (patch) | |
| tree | 66868830fc73a8f3a5b57ff704d6e789ed9d5fdc /predict_set.go | |
| parent | d6cbc0e9690035368477b3ed8aa22aece0381b77 (diff) | |
predict: split file
Diffstat (limited to 'predict_set.go')
| -rw-r--r-- | predict_set.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/predict_set.go b/predict_set.go new file mode 100644 index 0000000..8fc59d7 --- /dev/null +++ b/predict_set.go @@ -0,0 +1,19 @@ +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 +} |
