(dir, toComplete string)
| 26 | } |
| 27 | |
| 28 | func tomlFileCompletion(dir, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 29 | var fileNames []string |
| 30 | if fileio.PathExists(dir) { |
| 31 | entities, err := os.ReadDir(dir) |
| 32 | if err != nil { |
| 33 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 34 | } |
| 35 | |
| 36 | for _, entity := range entities { |
| 37 | if !entity.IsDir() && strings.HasSuffix(entity.Name(), ".toml") { |
| 38 | fileName := strings.TrimSuffix(entity.Name(), ".toml") |
| 39 | if strings.HasPrefix(fileName, toComplete) { |
| 40 | fileNames = append(fileNames, fileName) |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return fileNames, cobra.ShellCompDirectiveNoFileComp |
| 46 | } |
| 47 | |
| 48 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 49 | } |
no test coverage detected