Ascii diagrams with dot, graph-easy and docker 15 Nov 2016
Sometimes I find myself in the situation to generate some diagrams.
It’s nice to use a human readable format like dot to define these diagrams. Unfortunately graphviz doesn’t have an assci output mode.
A perl module exists to fill this void called graph-easy. It’s also possible to run this perl module via docker.
To generate graphs on the command line with docker and graph-easy you can run this command:
echo '[a]->[b]' | docker run -i tsub/graph-easy
Here is the result
+---+ +---+
| a | --> | b |
+---+ +---+
That’s it. You now have a ascii diagram of your graphviz. After the initial docker run, the command takes around a second to execute. This is fast enough for my purposes.
Learnings
- Use docker to run on-off tasks without cluttering your main computer.
- Use docker in combination with your regular shell scripts and within pipes.
- Docker can function as a operation system independent package manager.
- I can finally use perl modules without installing them in my system.