(pattern string, formatMatch func(string) string)
| 184 | } |
| 185 | |
| 186 | func findMatches(pattern string, formatMatch func(string) string) []flags.Completion { |
| 187 | paths, err := filepath.Glob(pattern) |
| 188 | if paths == nil || err != nil { |
| 189 | return nil |
| 190 | } |
| 191 | |
| 192 | matches := []flags.Completion{} |
| 193 | for _, path := range paths { |
| 194 | info, err := os.Stat(path) |
| 195 | if err != nil { |
| 196 | continue |
| 197 | } |
| 198 | |
| 199 | formattedMatch := formatMatch(path) |
| 200 | if info.IsDir() { |
| 201 | formattedMatch = fmt.Sprintf("%s%c", formattedMatch, os.PathSeparator) |
| 202 | } |
| 203 | matches = append(matches, flags.Completion{Item: formattedMatch}) |
| 204 | } |
| 205 | |
| 206 | return matches |
| 207 | } |
| 208 | |
| 209 | func completeWithTilde(prefix string) []flags.Completion { |
| 210 | var homeDir string |
no test coverage detected