MCPcopy
hub / github.com/rclone/rclone / addRemoteFiles

Function addRemoteFiles

cmd/completion.go:74–106  ·  view source on GitHub ↗

Add remote files to the completions being built up

(toComplete string, result cobra.ShellCompDirective, completions []string)

Source from the content-addressed store, hash-verified

72
73// Add remote files to the completions being built up
74func addRemoteFiles(toComplete string, result cobra.ShellCompDirective, completions []string) (cobra.ShellCompDirective, []string) {
75 ctx := context.Background()
76 parent, _, err := fspath.Split(toComplete)
77 if err != nil {
78 compLogf("Failed to split path %q: %v", toComplete, err)
79 return result, completions
80 }
81 f, err := cache.Get(ctx, parent)
82 if err == fs.ErrorIsFile {
83 completions = append(completions, toComplete)
84 return result, completions
85 } else if err != nil {
86 compLogf("Failed to make Fs %q: %v", parent, err)
87 return result, completions
88 }
89 fis, err := f.List(ctx, "")
90 if err != nil {
91 compLogf("Failed to list Fs %q: %v", parent, err)
92 return result, completions
93 }
94 for _, fi := range fis {
95 remote := fi.Remote()
96 path := parent + remote
97 if strings.HasPrefix(path, toComplete) {
98 if _, ok := fi.(fs.Directory); ok {
99 path += "/"
100 result |= cobra.ShellCompDirectiveNoSpace
101 }
102 completions = append(completions, path)
103 }
104 }
105 return result, completions
106}
107
108// Workaround doesn't seem to be needed for BashCompletionV2
109const useColonWorkaround = false

Callers 1

validArgsFunction · 0.85

Calls 5

SplitFunction · 0.92
GetFunction · 0.92
compLogfFunction · 0.85
ListMethod · 0.65
RemoteMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…