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) {