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

Function newPrompt

cli/cliui/prompt_test.go:228–247  ·  view source on GitHub ↗
(ctx context.Context, ptty *ptytest.PTY, opts cliui.PromptOptions, invOpt func(inv *serpent.Invocation))

Source from the content-addressed store, hash-verified

226}
227
228func newPrompt(ctx context.Context, ptty *ptytest.PTY, opts cliui.PromptOptions, invOpt func(inv *serpent.Invocation)) (string, error) {
229 value := ""
230 cmd := &serpent.Command{
231 Handler: func(inv *serpent.Invocation) error {
232 var err error
233 value, err = cliui.Prompt(inv, opts)
234 return err
235 },
236 }
237
238 inv := cmd.Invoke()
239 // Optionally modify the cmd
240 if invOpt != nil {
241 invOpt(inv)
242 }
243 inv.Stdout = ptty.Output()
244 inv.Stderr = ptty.Output()
245 inv.Stdin = ptty.Input()
246 return value, inv.WithContext(ctx).Run()
247}
248
249func TestPasswordTerminalState(t *testing.T) {
250 if os.Getenv("TEST_SUBPROCESS") == "1" {

Callers 1

TestPromptFunction · 0.85

Calls 6

PromptFunction · 0.92
WithContextMethod · 0.80
OutputMethod · 0.65
InputMethod · 0.65
RunMethod · 0.65
InvokeMethod · 0.45

Tested by

no test coverage detected