mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-09 12:21:57 -04:00
feat(export_browser_history): basic arg parsing error message
This commit is contained in:
parent
0043b59bc8
commit
2ff3fc434e
1 changed files with 22 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue