Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Created July 7, 2022 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingoutloud/3437fd469b944cf79567dc9788efcf38 to your computer and use it in GitHub Desktop.
Save codingoutloud/3437fd469b944cf79567dc9788efcf38 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Mostly this script exists to simply make it possible/simple to do "puml.sh foo.puml" to create "foo.png" from command line.
#
# If you want it even simpler - "puml foo.puml" (no ".sh" extension) consider using an alias.
# Here is example for .bash_profile:
# alias puml=~/bin/puml.sh
for ARG in "$@"
do
if [ "$ARG" = "v" ]; then
echo "Autoview enabled"
VIEW_PUML_OUTPUT_AUTOMATICALLY=$true
else
PUML=$ARG
PNG="${PUML%.*}.png"
if [ -f "$PUML" ]; then
# 💘➜↓↳⇢➤🏹➡️ ➡
echo "Compiling $PUML ➡️ $PNG"
java -jar ~/bin/plantuml.jar $PUML
if [ -z "$VIEW_PUML_OUTPUT_AUTOMATICALLY" ]; then
echo "Opening $PNG"
open -g "$PNG"
fi
else
echo "$PUML not found."
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment