Interactive asciicast editor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1003 B

package main
import (
"flag"
"os"
"os/signal"
"path"
"syscall"
)
var (
single bool
viewer bool
)
func main() {
var (
force bool
controlAddress string
)
flag.BoolVar(&force, "force", false, "force playback with insufficiently sized terminal")
flag.BoolVar(&viewer, "viewer", false, "run as viewer")
flag.BoolVar(&single, "single", false, "run as editor without connecting to a remote viewer")
flag.StringVar(&controlAddress, "control", "", "socket path or server address used to control viewer from editor")
flag.Parse()
if controlAddress == "" {
controlAddress = path.Join(os.TempDir(), "asciinema-editor.sock")
}
if viewer || single {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
go func() {
<-sigc
interruptPlayback()
resetScreen()
os.Exit(0)
}()
}
go handleCast()
if viewer {
runViewer(controlAddress)
return
}
runEditor(controlAddress, force)
}