helper-scripts/getweather.sh

38 lines
646 B
Bash
Raw Normal View History

#!/bin/bash
2018-08-27 13:30:54 -07:00
# Obtain a weather forecast
printHelp() {
cat << EOF
Retrieve the weather of a give location
Usage: getweather [-h|--help] [location]
Options:
-h show this help page
EOF
}
while true; do
case "${1}" in
"-h"|"--help")
printHelp
exit
;;
--)
shift
break
;;
-*)
echo "Not an option: ${1}" >&2 && exit 1
exit
;;
*)
break;
;;
esac
done
[[ -z "${@}" ]] && echo "Please enter a location" >&2 && exit 1
xargs --no-run-if-empty -I {} curl wttr.in/{} <<< "${@}"