diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/posener/complete/predict.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/posener/complete/predict.go')
-rw-r--r-- | vendor/github.com/posener/complete/predict.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/vendor/github.com/posener/complete/predict.go b/vendor/github.com/posener/complete/predict.go new file mode 100644 index 0000000..8207063 --- /dev/null +++ b/vendor/github.com/posener/complete/predict.go | |||
@@ -0,0 +1,41 @@ | |||
1 | package complete | ||
2 | |||
3 | // Predictor implements a predict method, in which given | ||
4 | // command line arguments returns a list of options it predicts. | ||
5 | type Predictor interface { | ||
6 | Predict(Args) []string | ||
7 | } | ||
8 | |||
9 | // PredictOr unions two predicate functions, so that the result predicate | ||
10 | // returns the union of their predication | ||
11 | func PredictOr(predictors ...Predictor) Predictor { | ||
12 | return PredictFunc(func(a Args) (prediction []string) { | ||
13 | for _, p := range predictors { | ||
14 | if p == nil { | ||
15 | continue | ||
16 | } | ||
17 | prediction = append(prediction, p.Predict(a)...) | ||
18 | } | ||
19 | return | ||
20 | }) | ||
21 | } | ||
22 | |||
23 | // PredictFunc determines what terms can follow a command or a flag | ||
24 | // It is used for auto completion, given last - the last word in the already | ||
25 | // in the command line, what words can complete it. | ||
26 | type PredictFunc func(Args) []string | ||
27 | |||
28 | // Predict invokes the predict function and implements the Predictor interface | ||
29 | func (p PredictFunc) Predict(a Args) []string { | ||
30 | if p == nil { | ||
31 | return nil | ||
32 | } | ||
33 | return p(a) | ||
34 | } | ||
35 | |||
36 | // PredictNothing does not expect anything after. | ||
37 | var PredictNothing Predictor | ||
38 | |||
39 | // PredictAnything expects something, but nothing particular, such as a number | ||
40 | // or arbitrary name. | ||
41 | var PredictAnything = PredictFunc(func(Args) []string { return nil }) | ||