From e3bd8f932d60f4f79cf19cecd6467ee6f3f09ebb Mon Sep 17 00:00:00 2001 From: Alejandro Angulo Date: Tue, 20 Dec 2022 09:40:52 -0800 Subject: [PATCH] Added additional params and added usage --- .cspell.json | 4 ++++ README.md | 18 ++++++++++++++++-- alejandro_resume.tex | 2 +- flake.nix | 21 +++++++++++++++++++-- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/.cspell.json b/.cspell.json index f250fae..a19a9dd 100644 --- a/.cspell.json +++ b/.cspell.json @@ -4,10 +4,14 @@ "words": [ "Everbridge", "ITS's", + "PHONENUMBER", "alacritty", + "angulo", "crkbd", "dotfiles", + "hardcode", "homelab", + "latexmk", "toolset" ], "flagWords": [] diff --git a/README.md b/README.md index c73fe6e..93b9137 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,23 @@ flake to build a resume generator command. Use the flake! ```bash -env EMAIL='foo@bar.com' PHONENUMBER='(555) 555-5555' nix run github:alejandro-angulo/resume +❯ nix run github:alejandro-angulo/resume -- -h + +Usage: alejandro-resume [-h] [-d] [-e EMAIL] [-p PHONENUMBER] + -h Prints this usage message. + + -d Saves latexmk log file (will be named alejandro_resume.log) + + -e EMAIL Sets email address used when building document. + Can also be set with EMAIL environment variable. + + -p PHONENUMBER Sets phone number used when building the document. + Can also be set with PHONENUMBER environment variable. + + +❯ nix run github:alejandro-angulo/resume -- -e 'foo@bar.com' -p '(555) 555-5555' ``` -The `EMAIL` and `PHONENUMBER` variables are required because I didn't want to +The email and phone number parameters are required because I didn't want to hardcode those in my tex file. Hopefully this helps prevent spammers from finding my personal contact information. diff --git a/alejandro_resume.tex b/alejandro_resume.tex index 6f1b736..f7c28d4 100644 --- a/alejandro_resume.tex +++ b/alejandro_resume.tex @@ -61,7 +61,7 @@ \fancyfoot[L]{ \small{The source code for this document is available at \href{https://github.com/alejandro-angulo/resume}{https://github.com/alejandro-angulo/resume}}\\ \small{If you have \href{https://nixos.wiki/wiki/Nix_package_manager}{nix} installed you can run the command below to generate the latest version of this document}\\ - \scriptsize{\texttt{env EMAIL='\email' PHONENUMBER='\phonenumber' nix run --refresh --experimental-features 'nix-command flakes' github:alejandro-angulo/resume/main}} + \scriptsize{\texttt{nix run --refresh --experimental-features 'nix-command flakes' github:alejandro-angulo/resume/main -- -e '\email' -p '\phonenumber'}} } \vspace*{0.175in} \hspace*{-2em} diff --git a/flake.nix b/flake.nix index 14529f1..bbbc03c 100644 --- a/flake.nix +++ b/flake.nix @@ -44,10 +44,27 @@ RES=$(pwd)/alejandro_resume.pdf LOG=$(pwd)/alejandro_resume.log - while getopts 'd' flag; do + function usage { + echo "Usage: $(basename $0) [-h] [-d] [-e EMAIL] [-p PHONENUMBER]" + echo ' -h Prints this usage message.' + echo "" + echo ' -d Saves latexmk log file (will be named alejandro_resume.log)' + echo "" + echo ' -e EMAIL Sets email address used when building document.' + echo ' Can also be set with EMAIL environment variable.' + echo "" + echo ' -p PHONENUMBER Sets phone number used when building the document.' + echo ' Can also be set with PHONENUMBER environment variable.' + } + + while getopts ':de:p:h' flag; do case $flag in 'd') DEBUG=true;; - *) echo 'TODO: Add usage';; + # Overrides EMAIL and PHONENUMBER envvars if set + 'e') EMAIL="$OPTARG";; + 'p') PHONENUMBER="$OPTARG";; + 'h') usage && exit;; + ?) usage && exit 1;; esac done