commit 8560fe020cb8b90317f0d3a2369a8b4a44e36eda Author: ksyasuda Date: Sat Sep 7 19:38:07 2024 -0700 initial commit 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