#!/bin/sh # shellcheck disable=1003 SCRIPT="$(basename "$0")" long='help,open' short='ho' if ! opts="$(getopt -o $short -l $long -n "$SCRIPT" -- "$@")"; then exit 1 fi eval set -- "$opts" help() { cat <<-EOF $SCRIPT Toby Vincent $SCRIPT Builds generic cover letter using the provided company name and address. USAGE: $SCRIPT
[OPTION ...] OPTIONS: -o, --open Open PDF after building -h, --help Show this help. EXAMPLES: $SCRIPT "Chuck's Clucks" "Cluckville, KY" --open EOF } open=false while true; do case "$1" in -h | --help) help exit 0 ;; -o | --open) open=true shift ;; --) shift break ;; *) exit 1 ;; esac done if [ "$#" -eq 0 ]; then echo 'Error: Missing name and address' help exit 1 fi name=$1 address=$2 shift 2 latexmk src/generic/cover_letter.tex -usepretex="\def\companyname{$name}\def\companyaddress{$address}" -g -jobname=custom_cover_letter "$@" cp src/generic/custom_cover_letter.pdf src/cover_letter.pdf if $open; then xdg-open src/cover_letter.pdf fi