# inspried from this forum post https://discourse.gohugo.io/t/script-to-install-latest-hugo-release-on-macos-and-ubuntu/14774/10
# if you have run into github api anonymous access limits which happens during debugging/dev then add user and token here or sourced from a separate file
# . ~/githubapitoken
#GITHUB_USER=""
#GITHUB_TOKEN=""
if [ "$GITHUB_TOKEN" != "" ]; then
echo using access token with script
echo $GITHUB_USER $GITHUB_TOKEN
fi
EXTENDED=false
FORCE=false
EFILE=""
# options
# e - download and install the extended version
# c - use 'hugoe' as the install command for extended version otherwise 'hugo' will launch extended version
# f - force download/overwrite of same version
declare OPTION
declare OPTARG
declare OPTIND
while getopts 'ecf' OPTION; do
case "$OPTION" in
e)
echo "installing extended hugo"
EXTENDED=true
;;
c)
if [ $EXTENDED = true ]; then
EFILE="e"
echo using hugoe for extended command
fi
;;
f)
echo "FORCING download/overwrite"
FORCE=true
;;
esac
done
shift $(( OPTIND - 1 ))
DEFAULT_BIN_DIR="/usr/local/bin"
# Single optional argument is directory in which to install hugo