MCPcopy Index your code
hub / github.com/coder/coder / installCompletion

Function installCompletion

cli/completion.go:73–97  ·  view source on GitHub ↗
(inv *serpent.Invocation, shell completion.Shell)

Source from the content-addressed store, hash-verified

71}
72
73func installCompletion(inv *serpent.Invocation, shell completion.Shell) error {
74 path, err := shell.InstallPath()
75 if err != nil {
76 cliui.Error(inv.Stderr, fmt.Sprintf("Failed to determine completion path %v", err))
77 return shell.WriteCompletion(inv.Stdout)
78 }
79 if !isTTYOut(inv) {
80 return shell.WriteCompletion(inv.Stdout)
81 }
82 choice, err := cliui.Select(inv, cliui.SelectOptions{
83 Options: []string{
84 "Confirm",
85 "Print to terminal",
86 },
87 Message: fmt.Sprintf("Install completion for %s at %s?", shell.Name(), path),
88 HideSearch: true,
89 })
90 if err != nil {
91 return err
92 }
93 if choice == "Print to terminal" {
94 return shell.WriteCompletion(inv.Stdout)
95 }
96 return completion.InstallShellCompletion(shell)
97}

Callers 1

completionMethod · 0.85

Calls 4

ErrorFunction · 0.92
SelectFunction · 0.92
isTTYOutFunction · 0.85
NameMethod · 0.65

Tested by

no test coverage detected