MCPcopy Create free account
hub / github.com/docker/docker-agent / completeAlias

Function completeAlias

cmd/root/completion.go:26–55  ·  view source on GitHub ↗
(toComplete string)

Source from the content-addressed store, hash-verified

24}
25
26func completeAlias(toComplete string) ([]string, cobra.ShellCompDirective) {
27 if strings.HasPrefix(toComplete, "/") || strings.HasPrefix(toComplete, ".") {
28 return completeAgentFilename(toComplete)
29 }
30
31 var candidates []string
32
33 // Add matching built-in agent names
34 for _, name := range config.BuiltinAgentNames() {
35 if strings.HasPrefix(name, toComplete) {
36 candidates = append(candidates, name+"\tbuilt-in agent")
37 }
38 }
39
40 // Add matching aliases
41 cfg, err := userconfig.Load()
42 if err == nil {
43 for k, v := range cfg.Aliases {
44 if strings.HasPrefix(k, toComplete) {
45 candidates = append(candidates, k+"\t"+v.Path)
46 }
47 }
48 }
49
50 // Also add matching YAML files from the current directory
51 fileCandidates, _ := completeAgentFilename(toComplete)
52 candidates = append(candidates, fileCandidates...)
53
54 return candidates, cobra.ShellCompDirectiveNoFileComp
55}
56
57func completeMessage(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
58 if !strings.HasPrefix(toComplete, "/") {

Callers 3

completeRunExecFunction · 0.85
TestCompleteAliasFunction · 0.85

Calls 3

BuiltinAgentNamesFunction · 0.92
LoadFunction · 0.92
completeAgentFilenameFunction · 0.85

Tested by 2

TestCompleteAliasFunction · 0.68