31 lines
554 B
Bash
31 lines
554 B
Bash
|
#!/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
|