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

Method completion

cmds/cmd_install.go:251–279  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string, toComplete string)

Source from the content-addressed store, hash-verified

249}
250
251func (i *installCmd) completion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
252 var suggestions []string
253
254 if fileio.PathExists(dirs.PortsDir) {
255 i.buildSuggestions(&suggestions, dirs.PortsDir, toComplete)
256 }
257
258 projectPortsDir := filepath.Join(dirs.ConfProjectsDir, i.celer.Project().GetName())
259 if fileio.PathExists(projectPortsDir) {
260 i.buildSuggestions(&suggestions, projectPortsDir, toComplete)
261 }
262
263 // Support flags completion.
264 commands := []string{
265 "--dev", "-d",
266 "--force", "-f",
267 "--recursive", "-r",
268 "--jobs", "-j",
269 "--verbose", "-v",
270 }
271
272 for _, flag := range commands {
273 if strings.HasPrefix(flag, toComplete) {
274 suggestions = append(suggestions, flag)
275 }
276 }
277
278 return suggestions, cobra.ShellCompDirectiveNoFileComp
279}

Callers 1

Calls 4

buildSuggestionsMethod · 0.95
PathExistsFunction · 0.92
GetNameMethod · 0.65
ProjectMethod · 0.65

Tested by 1