Added code to display help if no input is provided via stdin

master
Aaron Johnon 1 year ago
parent 3aa2bf9eb5
commit 5da5659957

@ -49,6 +49,13 @@ func main() {
flag.Parse()
// Check if there is input from stdin
info, _ := os.Stdin.Stat()
if (info.Mode() & os.ModeCharDevice) != 0 {
flag.Usage()
os.Exit(1)
}
// Read all input from stdin
reader := bufio.NewReader(os.Stdin)
inputBytes, _ := io.ReadAll(reader)

@ -99,6 +99,13 @@ func main() {
flag.Parse()
// Check if there is input from stdin
info, _ := os.Stdin.Stat()
if (info.Mode() & os.ModeCharDevice) != 0 {
flag.Usage()
os.Exit(1)
}
// Read input from stdin
reader := bufio.NewReader(os.Stdin)
input, _ := reader.ReadString('\n')

Loading…
Cancel
Save