Open renta opened 2 years ago
Thank you for reporting. Survey was not designed to take input from a stream that's not connected to a terminal, but I agree that we should avoid a panic and instead throw a more informative error message. Better yet, maybe Survey could work with any standard input stream, even if it's not a terminal.
To avoid this in your app for now, you should check whether os.Stdin
is a terminal, and avoid invoking Survey otherwise.
+1
Getting the same error when running a command that uses survey, running from the shell of http://github.com/google/zx
Zx is not a real terminal
What operating system and terminal are you using? Linux
An example that showcases the bug. Simple
yes
piping lead to a panic forsurvey.Confirm
andsurvey.AskOne
code. I have a cli-command which is asking yes-no on action confirmation. This is the code:It works well with an interactive input when I type yes or no. Bet when I use predefined answer like:
What did you expect to see? Next execution output of the command.
What did you see instead? I see panic. Top part of the stack: