summaryrefslogtreecommitdiff
path: root/flag.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-05 21:59:10 +0300
committerEyal Posener <[email protected]>2017-05-05 22:15:23 +0300
commit04d16f6064c7c71068f47b4e7106f15a05b6b326 (patch)
tree5498e40a0104754d5f06ccfd125c82d2d13b2931 /flag.go
parent5e07cbd4c20a5a3bb5bc84148dc4d4ebffa3d033 (diff)
Renamings
Diffstat (limited to 'flag.go')
-rw-r--r--flag.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/flag.go b/flag.go
deleted file mode 100644
index 645cb83..0000000
--- a/flag.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package complete
-
-import (
- "os"
- "path/filepath"
-)
-
-type FlagOptions struct {
- HasFollow bool
- FollowsOptions func() []Option
-}
-
-func (f *FlagOptions) follows() []Option {
- if f.FollowsOptions == nil {
- return nil
- }
- return f.FollowsOptions()
-}
-
-var (
- FlagNoFollow = FlagOptions{}
- FlagUnknownFollow = FlagOptions{HasFollow: true}
-)
-
-func FlagFileFilter(pattern string) FlagOptions {
- return FlagOptions{
- HasFollow: true,
- FollowsOptions: glob(pattern),
- }
-}
-
-func glob(pattern string) func() []Option {
- return func() []Option {
- files, err := filepath.Glob(pattern)
- if err != nil {
- logger("failed glob operation with pattern '%s': %s", pattern, err)
- }
- if !filepath.IsAbs(pattern) {
- filesToRel(files)
- }
- options := make([]Option, len(files))
- for i, f := range files {
- options[i] = ArgFileName(f)
- }
- return options
- }
-}
-func filesToRel(files []string) {
- wd, err := os.Getwd()
- if err != nil {
- return
- }
- for i := range files {
- abs, err := filepath.Abs(files[i])
- if err != nil {
- continue
- }
- rel, err := filepath.Rel(wd, abs)
- if err != nil {
- continue
- }
- files[i] = "./" + rel
- }
- return
-}