MCPcopy
hub / github.com/cli/cli / waitForEchoDisabled

Function waitForEchoDisabled

internal/prompter/accessible_prompter_test.go:963–976  ·  view source on GitHub ↗

waitForEchoDisabled polls the TTY until echo mode is disabled or the timeout is reached. This is used in password and auth token tests to ensure that huh has configured the terminal before we send input.

(tty *os.File, timeout time.Duration)

Source from the content-addressed store, hash-verified

961// timeout is reached. This is used in password and auth token tests to
962// ensure that huh has configured the terminal before we send input.
963func waitForEchoDisabled(tty *os.File, timeout time.Duration) error {
964 deadline := time.Now().Add(timeout)
965 for time.Now().Before(deadline) {
966 termios, err := unix.IoctlGetTermios(int(tty.Fd()), ioctlGetTermios)
967 if err != nil {
968 return fmt.Errorf("getting terminal attributes: %w", err)
969 }
970 if termios.Lflag&unix.ECHO == 0 {
971 return nil
972 }
973 time.Sleep(time.Millisecond)
974 }
975 return fmt.Errorf("timed out waiting for echo mode to be disabled")
976}

Callers 1

TestAccessiblePrompterFunction · 0.85

Calls 3

AddMethod · 0.65
FdMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected