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