summaryrefslogtreecommitdiff
path: root/option.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-06 22:21:03 +0300
committerGitHub <[email protected]>2017-05-06 22:21:03 +0300
commitc26ef096c7990a5ae97b503545fd76ff6df388d6 (patch)
treed0180b667269b985d15520f3b2e1aafc9292af6e /option.go
parent2b6aed2b1e974a733c0dc614a9617c33a54c208c (diff)
parent404634e843081e7010260bd95006b84d6c40a8fd (diff)
Merge pull request #4 from posener/doc
Doc
Diffstat (limited to 'option.go')
-rw-r--r--option.go42
1 files changed, 0 insertions, 42 deletions
diff --git a/option.go b/option.go
deleted file mode 100644
index 3915091..0000000
--- a/option.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package complete
-
-import (
- "path/filepath"
- "strings"
-)
-
-type Option interface {
- String() string
- Matches(prefix string) bool
-}
-
-type Arg string
-
-func (a Arg) String() string {
- return string(a)
-}
-
-func (a Arg) Matches(prefix string) bool {
- return strings.HasPrefix(string(a), prefix)
-}
-
-type ArgFileName string
-
-func (a ArgFileName) String() string {
- return string(a)
-}
-
-func (a ArgFileName) Matches(prefix string) bool {
- full, err := filepath.Abs(string(a))
- if err != nil {
- Log("failed getting abs path of %s: %s", a, err)
- }
- prefixFull, err := filepath.Abs(prefix)
- if err != nil {
- Log("failed getting abs path of %s: %s", prefix, err)
- }
-
- // if the file has the prefix as prefix,
- // but we don't want to show too many files, so, if it is in a deeper directory - omit it.
- return strings.HasPrefix(full, prefixFull) && (full == prefixFull || !strings.Contains(full[len(prefixFull)+1:], "/"))
-}