Last active
October 4, 2020 22:56
-
-
Save TheLandolorien/f01ce57a1a2c3626eacf757a6f76ab47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CONFIG_PATH="${HOME}/.inaudible/" | |
TABLES_PATH="${CONFIG_PATH}/tables/" | |
usage() { | |
echo "Usage: ${BASH_SOURCE[0]} <BOOK_FILE|BOOKS_DIRECTORY>" | |
if [[ ! -z "$1" ]]; then | |
echo "" | |
echo "$1" | |
fi | |
exit 1 | |
} | |
if [[ ! -d "$TABLES_PATH" ]]; then | |
mkdir -p "$TABLES_PATH" | |
fi | |
if [[ -z $(ls -A "$TABLES_PATH") ]]; then | |
git clone https://github.com/inAudible-NG/tables.git "$TABLES_PATH" | |
fi | |
if [[ "$#" -eq 1 ]]; | |
BOOKS_DIRECTORY="$1" | |
if [[ -f "$TABLES_PATH" ]]; then | |
BOOKS_DIRECTORY=$(basename "BOOKS_DIRECTORY") | |
fi | |
if [[ ! -d $"BOOKS_DIRECTORY" ]]; then | |
usage | |
fi | |
echo "Found ${BOOKS_DIRECTORY}!" | |
else | |
usage "ERROR: Invalid .aax file or directory" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment