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