isTTYIn returns whether the passed invocation is having stdin read from a TTY
(inv *serpent.Invocation)
| 1100 | |
| 1101 | // isTTYIn returns whether the passed invocation is having stdin read from a TTY |
| 1102 | func 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 |
| 1118 | func isTTYOut(inv *serpent.Invocation) bool { |
no test coverage detected