mirror of
				https://github.com/syssecfsu/witty.git
				synced 2025-11-04 08:17:30 +01:00 
			
		
		
		
	add -w to cmdline replay
This commit is contained in:
		
							parent
							
								
									b673b172f0
								
							
						
					
					
						commit
						0c5915677e
					
				@ -2,6 +2,7 @@ package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"flag"
 | 
			
		||||
	"io"
 | 
			
		||||
	"log"
 | 
			
		||||
	"os"
 | 
			
		||||
@ -16,11 +17,19 @@ type writeRecord struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	if len(os.Args) != 2 {
 | 
			
		||||
		log.Fatalln("Usage: replay <recordfile>")
 | 
			
		||||
	var wait uint
 | 
			
		||||
 | 
			
		||||
	flag.UintVar(&wait, "w", 2000, "Max wait time between outputs")
 | 
			
		||||
	flag.UintVar(&wait, "wait", 2000, "Max wait time between outputs")
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
 | 
			
		||||
	left := flag.Args()
 | 
			
		||||
 | 
			
		||||
	if len(left) != 1 {
 | 
			
		||||
		log.Fatalln("Usage: replay -w/wait time <recordfile>")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fp, err := os.Open(os.Args[1])
 | 
			
		||||
	fp, err := os.Open(left[0])
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatalln("Failed to open record file", err)
 | 
			
		||||
@ -31,7 +40,7 @@ func main() {
 | 
			
		||||
		io.Writer
 | 
			
		||||
	}{os.Stdin, os.Stdout}
 | 
			
		||||
 | 
			
		||||
	t := term.NewTerminal(screen, ">")
 | 
			
		||||
	t := term.NewTerminal(screen, "$")
 | 
			
		||||
 | 
			
		||||
	if t == nil {
 | 
			
		||||
		log.Fatalln("Failed to create terminal")
 | 
			
		||||
@ -61,6 +70,10 @@ func main() {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if record.Dur > time.Duration(wait)*time.Millisecond {
 | 
			
		||||
			record.Dur = time.Duration(wait) * time.Millisecond
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		time.Sleep(record.Dur)
 | 
			
		||||
		t.Write(record.Data)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
echo "Try to resize shell with shell command"
 | 
			
		||||
printf '\e[8;36;120t'
 | 
			
		||||
clear
 | 
			
		||||
$(dirname $0)/replay $1
 | 
			
		||||
$(dirname $0)/replay "$@"
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user