Allow specifying custom database name to init

This commit is contained in:
Lukáš Kucharczyk 2022-11-15 22:16:05 +01:00
parent dcbc0b23d6
commit 90f436fb23
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 5 additions and 4 deletions

9
tag.sh
View File

@ -34,9 +34,10 @@ log() {
}
init() {
[ -f "$DB_FILE" ] && fail "Database file \"$DB_FILE\" already exists. Aborting."
cat "$DB_SCHEMA" | sqlite3 "$DB_FILE"
log "Empty database file \"$DB_FILE\" created."
# DB_NAME
[ -f "$1" ] && fail "Database file \"$1\" already exists. Aborting."
cat "$DB_SCHEMA" | sqlite3 "$1"
log "Empty database file \"$1\" created."
}
enumerate_positional_parameters() {
@ -126,7 +127,7 @@ add_path_auto() {
main() {
if [[ "$1" = "init" ]]; then
init
init "${2:-$DB_FILE}"
exit 0
fi