@@ 7,6 7,7 @@ import (
"log"
"runtime"
"strconv"
+ "time"
"git.sr.ht/~mna/zzcsi"
"git.sr.ht/~mna/zzterm"
@@ 15,13 16,15 @@ import (
func main() {
var (
- flagCSI = flag.Bool("csi", false, "Run in CSI test mode.")
- flagEcho = flag.Bool("echo", false, "Run in zero-allocation echo mode.")
- flagInfo = flag.Bool("info", true, "Run in information mode (default).")
+ flagCSI = flag.Bool("csi", false, "Run in CSI test mode.")
+ flagEcho = flag.Bool("echo", false, "Run in zero-allocation echo mode.")
+ flagInfo = flag.Bool("info", true, "Run in information mode (default).")
+ flagTimeout = flag.Duration("timeout", 0, "Read timeout.")
+ flagCloseAfter = flag.Duration("close-after", 0, "Close terminal fd after this duration.")
)
flag.Parse()
- t, err := term.Open("/dev/tty", term.RawMode)
+ t, err := term.Open("/dev/tty", term.RawMode, term.ReadTimeout(*flagTimeout))
if err != nil {
log.Panic(err)
}
@@ 30,6 33,13 @@ func main() {
t.Close()
}()
+ if *flagCloseAfter > 0 {
+ go func() {
+ <-time.After(*flagCloseAfter)
+ t.Close()
+ }()
+ }
+
switch {
case *flagCSI:
csiMode(t)