Diagram
Diagram is a CLI tool to generate hand drawn diagrams from ASCII arts.
It's a full featured CLI application which converts the ASCII text into hand drawn diagrams. The CLI part is based on gocui and the ascii to png conversion is done using the gg library.

Installation and usage
$ go get github.com/esimov/diagram
$ go install
# Start the application
$ diagram
A shell script is included to watch the output folder changes and automatically open the generated png files, however inotifywait
is required for Linux distribution. To install on Ubuntu please run:
sudo apt install inotify-tools
After this you can use the provided shell script by running $ ./watch
.
Update:
The included shell script is not needed anymore, because an internal image viewer is bundled into the application.
Command Line support
The application supports the generation of hand drawn diagrams directly via command line. Typing $ diagram --help
will show the supported commands for generating the diagrams without to enter the CLI tool:
Usage of diagram:
-font string
path to font file (default "${GOPATH}/src/github.com/esimov/diagram/font/gloriahallelujah.ttf")
-in string
Source
-out string
Destination
-preview
Show the preview window (default true)
CLI Examples
Read input from sample.txt
and write image to sample.png
showing a preview window with the hand drawn diagram:
diagram -in sample.txt -out sample.png
Read input from sample.txt
and write image to sample.png
, and exit immediately without showing a preview window:
diagram -in sample.txt -out sample.png -preview=false
Generate diagram as above but use a font at a different location:
diagram -in sample.txt -out sample.png -preview=false -font /path/to/my/font/MyHandwriting.ttf
Key bindings
Key |
Description |
Tab |
Next Panel |
Shift+Tab |
Previous Panel |
Ctrl+s |
Open Save Diagram Modal |
Ctrl+s |
Save Diagram |
Ctrl+d |
Convert Ascii to PNG |
Ctrl+x |
Clear the editor content |
Ctrl+z |
Restore the editor content |
PageUp |
Jump to the top |
PageDown |
Jump to the bottom |
Home |
Jump to the line start |
End |
Jump to the line end |
Ctrl+c |
Quit |
Example
Input |
Output |
 |
 |
Issues
The app was tested on Ubuntu and MacOS, but on Mac the panels are not selectables with clicks.
Acknowledgements
The ascii to png conversion was ported from shaky.dart.
License
This project is under the MIT License. See the LICENSE file for the full license text.