summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fetch_input.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/fetch_input.sh b/bin/fetch_input.sh
index 6b27931..d3a96ec 100755
--- a/bin/fetch_input.sh
+++ b/bin/fetch_input.sh
@@ -1,4 +1,5 @@
#!/bin/sh -eu
+# vim: sw=2 et
COOKIES="${HOME}/.adventofcode.json"
@@ -11,6 +12,20 @@ MODE="wget"
# https://stackoverflow.com/q/21919156/how-do-i-copy-cookies-from-chrome
SESSION=$(jq < "${COOKIES}" '."session-cookie"')
+check_dependency_availability() {
+ local bin
+
+ for bin in 'elinks' \
+ 'jq' \
+ 'wget'
+ do
+ if ! which "${bin}" >/dev/null; then
+ echo "Missing dependency: ${bin}" >&2
+ exit 1
+ fi
+ done
+}
+
concat() {
local part
@@ -26,6 +41,8 @@ authenticated_wget() {
"${@}"
}
+check_dependency_availability
+
if [ "${MODE}" = 'wget' ]; then
cd "${YEAR}"
cd 'rust'