skeleton for testing purposes
This commit is contained in:
1 parent
8076b30e3f
commit
71e4f1294e
11 files changed
+273
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Listen() {
|
||||
reader := bufio.NewScanner(os.Stdin)
|
||||
|
||||
fmt.Print("> ")
|
||||
|
||||
for {
|
||||
|
||||
if !reader.Scan() {
|
||||
log.Println("Program terminated (SIGINT)")
|
||||
return
|
||||
}
|
||||
|
||||
if err := reader.Err(); err != nil {
|
||||
log.Printf("Console input error: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
text := strings.TrimSpace(reader.Text())
|
||||
|
||||
switch text {
|
||||
case "exit":
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user