ReadInput from stdin if something is detected or ask the user for an input using the given prompt.
(prompt string)
| 74 | // ReadInput from stdin if something is detected or ask the user for an input |
| 75 | // using the given prompt. |
| 76 | func ReadInput(prompt string) ([]byte, error) { |
| 77 | st, err := stdin.Stat() |
| 78 | if err != nil { |
| 79 | return nil, errors.Wrap(err, "error reading data") |
| 80 | } |
| 81 | |
| 82 | if st.Size() == 0 && st.Mode()&os.ModeNamedPipe == 0 { |
| 83 | return ui.PromptPassword(prompt) |
| 84 | } |
| 85 | |
| 86 | return ReadAll(stdin) |
| 87 | } |
| 88 | |
| 89 | // ReadFile returns the contents of the file identified by name. It reads from |
| 90 | // STDIN if name is a hyphen ("-"). |
searching dependent graphs…