diff options
| author | Eyal Posener <[email protected]> | 2017-05-06 22:06:49 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2017-05-06 22:15:15 +0300 |
| commit | 703dd6ebc30f7c6f5a5c02e07a307e0e34d9c2c2 (patch) | |
| tree | 6efd5f6d1205eb6188193c86f5dd1e256b8996c5 /option.go | |
| parent | 9963a854946be0603f9e79ccba0a8b2688b20053 (diff) | |
improve docs
Diffstat (limited to 'option.go')
| -rw-r--r-- | option.go | 42 |
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:], "/")) -} |
