From 8560fe020cb8b90317f0d3a2369a8b4a44e36eda Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Sat, 7 Sep 2024 19:38:07 -0700 Subject: [PATCH] initial commit --- archiveit.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 archiveit.sh diff --git a/archiveit.sh b/archiveit.sh new file mode 100755 index 0000000..201968d --- /dev/null +++ b/archiveit.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +BASE_URL=https://archive.is/timegate +BROWSER=firefox + +check() { + article="$1" + if [ -z "$article" ]; then + echo "Please provide an article to archive" >&2 + exit 1 + fi +} + +while getopts "o:p:" opt; do + case $opt in + o) + article="$OPTARG" + check "$article" + $BROWSER "$BASE_URL/$article" + ;; + p) + article="$OPTARG" + check "$article" + printf "%s\n" "$BASE_URL/$article" + ;; + *) + echo "Invalid option: $OPTARG" >&2 + ;; + esac +done