andyk / ht

headless terminal - wrap any binary with a terminal interface for easy programmatic access.
Apache License 2.0
781 stars 14 forks source link

feature: integration of asciinema asciicast v2 format #8

Open ah-quant opened 5 months ago

ah-quant commented 5 months ago

This looks like it really wants to integrate https://github.com/asciinema/asciinema to record and replay interactions.

It might also be useful to check out https://github.com/oilshell/oil/wiki/Headless-Mode

pzmarzly commented 5 months ago

The oil shell's headless mode looks really interesting, but from what I understand from the docs, it only runs the shell (interactive prompt) headlessly, not the whole terminal? I.e. it doesn't allocate pty, capture input/output of child processes into variables, handle signals, etc. Or does it?

I'm not sure how oil shell is related to asciinema though.

And speaking of asciinema, does ht asciinema rec lalala.rec not just work? I haven't tried, but I don't see a reason why nesting pty-s like that shouldn't work.

ah-quant commented 5 months ago

My issue description was severely lacking, sorry. I meant asciinema integration concerning the https://docs.asciinema.org/manual/asciicast/v2/ format, not wrapping the cli program itself. That would natively and with low effort support watching the current session, reviewing sessions and storage of sessions without the need to interact with a new format - and it comes with a server, web player and additional tooling. With ht using avt, this should be doable (I never used asciinema as a library, but there has to be some overlap).

The headless mode of Oil is also interesting concerning the protocol used. A headless shell still has to communicate with a client; oil did a lot of research and documented things in the wiki concerning this problem space. They might provide some inspiration or an opportunity for cooperation. At least it beats reinventing the wheel and introducing another format :-)

ku1ik commented 4 months ago

Adding an option to save a session in asciinema's asciicast v2 format sounds like a useful and relatively straightforward thing, yeah! :+1: