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

Function isTTYIn

cli/root.go:1102–1115  ·  view source on GitHub ↗

isTTYIn returns whether the passed invocation is having stdin read from a TTY

(inv *serpent.Invocation)

Source from the content-addressed store, hash-verified

1100
1101// isTTYIn returns whether the passed invocation is having stdin read from a TTY
1102func isTTYIn(inv *serpent.Invocation) bool {
1103 // If the `--force-tty` command is available, and set,
1104 // assume we're in a tty. This is primarily for cases on Windows
1105 // where we may not be able to reliably detect this automatically (ie, tests)
1106 forceTty, err := inv.ParsedFlags().GetBool(varForceTty)
1107 if forceTty && err == nil {
1108 return true
1109 }
1110 file, ok := inv.Stdin.(*os.File)
1111 if !ok {
1112 return false
1113 }
1114 return isatty.IsTerminal(file.Fd())
1115}
1116
1117// isTTYOut returns whether the passed invocation is having stdout written to a TTY
1118func isTTYOut(inv *serpent.Invocation) bool {

Callers 4

loginMethod · 0.85
secretCreateMethod · 0.85
readInvocationStdinFunction · 0.85
stdinMethod · 0.85

Calls 1

IsTerminalMethod · 0.80

Tested by

no test coverage detected