aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/posener/complete/match
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/posener/complete/match')
-rw-r--r--vendor/github.com/posener/complete/match/file.go19
-rw-r--r--vendor/github.com/posener/complete/match/match.go6
-rw-r--r--vendor/github.com/posener/complete/match/prefix.go9
3 files changed, 34 insertions, 0 deletions
diff --git a/vendor/github.com/posener/complete/match/file.go b/vendor/github.com/posener/complete/match/file.go
new file mode 100644
index 0000000..051171e
--- /dev/null
+++ b/vendor/github.com/posener/complete/match/file.go
@@ -0,0 +1,19 @@
1package match
2
3import "strings"
4
5// File returns true if prefix can match the file
6func File(file, prefix string) bool {
7 // special case for current directory completion
8 if file == "./" && (prefix == "." || prefix == "") {
9 return true
10 }
11 if prefix == "." && strings.HasPrefix(file, ".") {
12 return true
13 }
14
15 file = strings.TrimPrefix(file, "./")
16 prefix = strings.TrimPrefix(prefix, "./")
17
18 return strings.HasPrefix(file, prefix)
19}
diff --git a/vendor/github.com/posener/complete/match/match.go b/vendor/github.com/posener/complete/match/match.go
new file mode 100644
index 0000000..812fcac
--- /dev/null
+++ b/vendor/github.com/posener/complete/match/match.go
@@ -0,0 +1,6 @@
1package match
2
3// Match matches two strings
4// it is used for comparing a term to the last typed
5// word, the prefix, and see if it is a possible auto complete option.
6type Match func(term, prefix string) bool
diff --git a/vendor/github.com/posener/complete/match/prefix.go b/vendor/github.com/posener/complete/match/prefix.go
new file mode 100644
index 0000000..9a01ba6
--- /dev/null
+++ b/vendor/github.com/posener/complete/match/prefix.go
@@ -0,0 +1,9 @@
1package match
2
3import "strings"
4
5// Prefix is a simple Matcher, if the word is it's prefix, there is a match
6// Match returns true if a has the prefix as prefix
7func Prefix(long, prefix string) bool {
8 return strings.HasPrefix(long, prefix)
9}