asciinema-editor/main.go

55 lines
1003 B
Go
Raw Permalink Normal View History

2020-10-23 17:58:10 +00:00
package main
import (
"flag"
"os"
2020-10-23 20:38:54 +00:00
"os/signal"
2020-10-23 17:58:10 +00:00
"path"
2020-10-23 20:38:54 +00:00
"syscall"
)
var (
single bool
viewer bool
2020-10-23 17:58:10 +00:00
)
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")
}
2020-10-23 20:38:54 +00:00
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()
2020-10-23 17:58:10 +00:00
if viewer {
runViewer(controlAddress)
return
}
2020-10-23 20:38:54 +00:00
runEditor(controlAddress, force)
2020-10-23 17:58:10 +00:00
}