MCPcopy Create free account
hub / github.com/github/gh-aw / PromptSecretInput

Function PromptSecretInput

pkg/console/input.go:16–45  ·  view source on GitHub ↗

PromptSecretInput shows an interactive password input prompt with masking The input is masked for security and includes validation Returns the entered secret value or an error

(title, description string)

Source from the content-addressed store, hash-verified

14// The input is masked for security and includes validation
15// Returns the entered secret value or an error
16func PromptSecretInput(title, description string) (string, error) {
17 // Check if stdin is a TTY - if not, we can't show interactive forms
18 if !tty.IsStderrTerminal() {
19 return "", errors.New("interactive input not available (not a TTY)")
20 }
21
22 var value string
23
24 form := huh.NewForm(
25 huh.NewGroup(
26 huh.NewInput().
27 Title(title).
28 Description(description).
29 EchoMode(huh.EchoModePassword). // Masks input for security
30 Validate(func(s string) error {
31 if s == "" {
32 return errors.New("value cannot be empty")
33 }
34 return nil
35 }).
36 Value(&value),
37 ),
38 ).WithTheme(styles.HuhTheme).WithAccessible(IsAccessibleMode())
39
40 if err := form.Run(); err != nil {
41 return "", err
42 }
43
44 return value, nil
45}

Callers 2

resolveSecretValueForSetFunction · 0.92
TestPromptSecretInputFunction · 0.70

Calls 4

IsStderrTerminalFunction · 0.92
IsAccessibleModeFunction · 0.85
ValidateMethod · 0.45
RunMethod · 0.45

Tested by 1

TestPromptSecretInputFunction · 0.56