Is it possible to "script" asciinema?

In dorothy we automate inputs in our tests like so:

	{
		sleep "$delay"
		__print_string "$down" # down to second preference
		sleep "$delay"
		__print_string "$enter" # select second preference
		sleep "$delay"
		__print_string "$escape" # cancel the confirmation of second preference
		sleep "$delay"
		__print_string "$enter" # change mind, do select second preference
		sleep "$delay"
		__print_string "$enter" # confirm second preference
	} | eval-tester --name='select second preference then cancel that, select second preference then confirm that' --stdout='c' \
		-- choose 'q' 'd' --confirm --required --default=b --default=c --default=d -- a b c d

I’m considering redoing our echo-style command to support input characters, such that that would become:


	export ECHO_STYLE__DEFAULT_SLEEP="$delay"
	echo-style --sleep+down --sleep+enter --sleep+escape --sleep+enter --sleep+enter | \
	eval-tester --name='select second preference then cancel that, select second preference then confirm that' --stdout='c' \
		-- choose 'q' 'd' --confirm --required --default=b --default=c --default=d -- a b c d

For sending inputs to asciinema, this could become:

echo-style --sleep+down --sleep+enter --sleep+escape --sleep+enter --sleep+enter | \
asciinema rec --stdin

# or even something like this
export ECHO_STYLE__PRINT_DELAY="$delay"
echo-style --down --enter --escape --enter --enter | \
asciinema rec --stdin 

Let me know if that would be of interest.

However, I think that my suggestion of a asciinema replay <cast> would be a suitable alternative to this need though.

1 Like