aniwrapper/db.sh

46 lines
826 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2021-10-30 12:38:42 -07:00
DIR=$HOME/.ani-cli
DB='history.sqlite3'
log() {
printf "%s\n" "$1"
}
while getopts 'cdrq' OPT; do
case "$OPT" in
c)
log "Creating database..."
sqlite3 "$DIR"/"$DB" <sql/search_history_tbl.sql
sqlite3 "$DIR"/"$DB" <sql/watch_history_tbl.sql
log "Created database..."
;;
d)
log "Deleting database..."
2021-10-30 12:38:42 -07:00
echo "$DIR/$DB"
rm "$DIR/$DB"
log "Database deleted..."
;;
r)
log "Deleting database..."
rm -rf "$DIR"/"$DB"
mkdir -p "$DIR"
log "Database deleted..."
log "Creating database..."
sqlite3 "$DIR"/"$DB" <sql/search_history_tbl.sql
sqlite3 "$DIR"/"$DB" <sql/watch_history_tbl.sql
log "Created database..."
;;
q)
log "Connecting to database..."
2021-10-30 12:38:42 -07:00
sqlite3 "$DIR/$DB"
log "Ending connection to databse..."
;;
*)
log "Don't get here"
exit 1
;;
esac
done