diff options
author | stuebinm | 2021-09-04 16:30:19 +0200 |
---|---|---|
committer | stuebinm | 2021-09-04 16:30:19 +0200 |
commit | cf10164ccc1f937ce059acbb2b426a2beb1ffdd0 (patch) | |
tree | 927279976a6f0e9566469b7e075cb389fc1f8ba3 /isabat | |
parent | 531dc149df8c1ba62ee7875f819a94d789935385 (diff) |
add some sanity checks to isabat
(will now print errors if bat/the highlighter theme is missing)
Diffstat (limited to '')
-rwxr-xr-x | isabat | 18 | ||||
-rw-r--r-- | isabat.nix | 2 |
2 files changed, 19 insertions, 1 deletions
@@ -1,12 +1,28 @@ #!/usr/bin/env bash set -euo pipefail +if ! type bat > /dev/null +then + echo "Error: \$PATH appears to lack bat. Please install it to use isabat." + exit 1 +fi + +if [ $( bat --list-languages | grep Isabelle | wc -l) -eq 0 ] +then + echo "Error: your installation of \`bat\` lacks a syntax highlighter for Isabelle." + echo "" + echo "Please place the isabelle.sublime-syntax file in $( bat --config-dir)/syntaxes," + echo "then run \`bat cache --build\` to make it available to bat." + exit 1 +fi + + if [ $# -eq 0 ] then echo "isabat: pretty-print isabelle theories on a terminal using bat." echo "" echo "please provide a .thy file to display." - exit + exit 1 fi cat "$1" | isabelle2unicode | bat --file-name "$1" --theme TwoDark @@ -17,6 +17,8 @@ stdenv.mkDerivation { cp $src isabat substituteInPlace isabat \ --replace isabelle2unicode "${isabelle-unicode}/bin/isabelle2unicode" + substituteInPlace isabat \ + --replace " bat " " ${pkgs.bat}/bin/bat " cp isabat $out ''; } |