From d0c89991bee9affef094ec62486140197636058f Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 23 Jan 2022 19:14:43 +0000 Subject: [PATCH] Allow exporting from a non-default db location. I'm running over NFS on this instance. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3789 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 42d008fb..a65531ac 100644 --- a/src/main.c +++ b/src/main.c @@ -238,10 +238,12 @@ xopt_help: static int _tf_command_export(const char* file, int argc, char* argv[]) { typedef struct args_t { + const char* db_path; bool help; } args_t; xoptOption options[] = { + { "db-path", 'd', offsetof(args_t, db_path), NULL, XOPT_TYPE_STRING, NULL, "Sqlite database path (default: db.sqlite)." }, { "help", 'h', offsetof(args_t, help), NULL, XOPT_TYPE_BOOL, NULL, "Shows this help message." }, XOPT_NULLOPTION, }; @@ -261,7 +263,12 @@ static int _tf_command_export(const char* file, int argc, char* argv[]) } return 2; } - tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, NULL, NULL); + sqlite3* db = NULL; + if (args.db_path) + { + sqlite3_open(args.db_path, &db); + } + tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db, NULL); if (extra_count) { for (int i = 0; i < extra_count; i++) @@ -284,6 +291,10 @@ static int _tf_command_export(const char* file, int argc, char* argv[]) } } tf_ssb_destroy(ssb); + if (db) + { + sqlite3_close(db); + } if (extras) {