#!/bin/zsh
use office/latex
#####################################################################
MAIN() {
[ ! $1 ] && FAIL 1 'must provide filename'
local FILENAME=$(LATEX__GET_MAIN_FILENAME "$1")
local ARGS=(-interaction=nonstopmode)
ARGS+=("$FILENAME")
cd "$(dirname $FILENAME)"
STATUS 'running compile (1/2)'
pdflatex ${ARGS[@]} \
|| FAIL 2 'first compile failed (see above)'
STATUS 'running compile (2/2)'
pdflatex ${ARGS[@]} >/dev/null 2>&1 \
|| FAIL 3 'second compile failed :c'
SUCCESS "created '$(echo $FILENAME | sed 's/\.[^.]*$/.pdf/')'"
}