feat(export_browser_history): basic arg parsing error message

This commit is contained in:
Phil Crockett 2025-02-16 08:31:21 +01:00
parent 0043b59bc8
commit 2ff3fc434e

View file

@ -11,10 +11,10 @@
# firefox_bookmarks.json
# safari_history.json
BROWSER_TO_EXPORT="${1?Please specify --chrome, --firefox, or --safari}"
OUTPUT_DIR="$(pwd)"
if [[ "$1" == "--chrome" ]]; then
# Google Chrome / Chromium
export_chrome() {
if [[ -e "$2" ]]; then
cp "$2" "$OUTPUT_DIR/chrome_history.db.tmp"
else
@ -30,10 +30,9 @@ if [[ "$1" == "--chrome" ]]; then
rm "$OUTPUT_DIR"/chrome_history.db.*
echo "Chrome history exported to:"
echo " $OUTPUT_DIR/chrome_history.json"
fi
}
if [[ "$1" == "--firefox" ]]; then
# Firefox
export_firefox() {
if [[ -e "$2" ]]; then
cp "$2" "$OUTPUT_DIR/firefox_history.db.tmp"
else
@ -67,10 +66,9 @@ if [[ "$1" == "--firefox" ]]; then
echo "Firefox history exported to:"
echo " $OUTPUT_DIR/firefox_history.json"
echo " $OUTPUT_DIR/firefox_bookmarks.json"
fi
}
if [[ "$1" == "--safari" ]]; then
# Safari
export_safari() {
if [[ -e "$2" ]]; then
cp "$2" "$OUTPUT_DIR/safari_history.db.tmp"
else
@ -85,4 +83,15 @@ if [[ "$1" == "--safari" ]]; then
rm "$OUTPUT_DIR"/safari_history.db.*
echo "Safari history exported to:"
echo " $OUTPUT_DIR/safari_history.json"
}
if [[ "$BROWSER_TO_EXPORT" == "--chrome" ]]; then
export_chrome "$@"
elif [[ "$BROWSER_TO_EXPORT" == "--firefox" ]]; then
export_firefox "@"
elif [[ "$BROWSER_TO_EXPORT" == "--safari" ]]; then
export_safari "$@"
else
echo "Unrecognized argument: $1" >&2
exit 1
fi