#!/bin/sh CDPATH='' cd -- "$(dirname -- "$0")" || exit SCRIPT="$(basename "$0")" long='help,open,all,name:,address:' short='hoAn:a:' if ! opts="$(getopt -o $short -l $long -n "$SCRIPT" -- "$@")"; then exit 1 fi eval set -- "$opts" help() { cat <<-EOF $SCRIPT Toby Vincent $SCRIPT Builds resume and cover letter. USAGE: $SCRIPT [OPTIONS...]
-- [LATEXMK_OPTS...] OPTIONS: -A, --all Build all cover letters -n, --name Specify a company name to use for generic cover letter -a, --address Specify a company address to use for generic cover letter -o, --open Open combined PDF after building -h, --help Show this help. EXAMPLES: $SCRIPT -n "Chuck's Clucks" -a "Cluckville, KY" --open EOF } error() { printf 'Error: %s' "$1" 1>&2 help exit 1 } path="." pretex="" while true; do case "$1" in -h | --help) help exit 0 ;; -n | --name) if [ -e "$2/cover_letter.tex" ]; then path=$2 else pretex="${pretex:--usepretex=}\def\companyname{$2}" fi shift 2 ;; -a | --address) pretex="${pretex:--usepretex=}\def\companyaddress{$2}" shift 2 ;; --) shift break ;; *) exit 1 ;; esac done typst compile resume.typ typst compile "$path"/cover_letter.typ pdfunite cover_letter.pdf resume.pdf cover_letter-resume.pdf