summaryrefslogtreecommitdiff
path: root/predict_set.go
diff options
context:
space:
mode:
Diffstat (limited to 'predict_set.go')
-rw-r--r--predict_set.go19
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
+}