MCPcopy Create free account
hub / github.com/celer-pkg/celer / tomlFileCompletion

Function tomlFileCompletion

cmds/completion_helper.go:28–49  ·  view source on GitHub ↗
(dir, toComplete string)

Source from the content-addressed store, hash-verified

26}
27
28func 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}

Callers 2

projectCompletgionFunction · 0.85
platformCompletgionFunction · 0.85

Calls 2

PathExistsFunction · 0.92
NameMethod · 0.65

Tested by

no test coverage detected