3 ms·
About a year ago, I hacked on an internal project that was exploring command-line interactions as code. Think of it like an animated CLI documentation factory.
by boilerupnc 7y ago
About a year ago, I hacked on an internal project that was exploring command-line interactions as code. Think of it like an animated CLI documentation factory. I believed and continue to believe, that short CLI animations give context to CLI usage and allow pause/copy/paste (game changer for watchers) if not in svg/gif which helps with consumability. Problem in my mind has always been keeping them up to date at scale (or their educational value diminishes). The project had a git repo that housed a collection of files following a light-weight syntax. Some complementary tooling "understood" this syntax and could create asciinema recordings while controlling pacing and execution. We then evolved this workflow into a FaaS triggered via PR and a github bot. Would like to potentially open-source the whole thing if I find some time to go through our internal approvals.
NET: Folks could add to the corpus following the modular syntax and issue a PR. About 3-5 minutes later, comments on the PR stream would have an animated svg/gif generated and added by the bot for review. If you liked how it looked, you accepted the PR. This corpus could then grow and be updated with minimal effort. A version of the client was modded to support self-signed certs and block accidental public upload.
We ported asciinema to a helm chart that could run multiple versions on a k8s cluster per ingress path to complete the story. The whole apparatus existed entirely behind the firewall.
- toomuchtodo 7y agoPlease open source this if you can!
- whelming_wave 7y agoYou might be able to create something similar by combining expect with asciinema, like $ expect_command=' log_user 0 spawn bash interact timeout 1 return send "ps aux | rg asciinema\n" interact timeout 3 return exit ' $ asciinema rec somefile -c 'expect -c '\'"$expect_command"\' using interact timeout as a sort of checkpoint to show output, though if you want to send single quotes you'll have to make sure they get escaped in the inner command (or just have the script in a file for expect to read)