|
7 | 7 |
|
8 | 8 |
|
9 | 9 | #define GENERATE_SQLITE_DATABASE 0 |
10 | | -#define DOCBUILDER_VERSION "0.2" |
| 10 | +#define DOCBUILDER_VERSION "0.3" |
11 | 11 |
|
12 | 12 | #include <stdio.h> |
13 | 13 | #include <fcntl.h> |
@@ -46,8 +46,9 @@ bool strip_jsx = false; |
46 | 46 | bool strip_md_title = false; |
47 | 47 | bool strip_astro_header = false; |
48 | 48 | bool use_transaction = false; |
49 | | -bool use_create_db = false; |
50 | 49 | bool json_mode = false; |
| 50 | +bool use_database = false; |
| 51 | +bool create_db = false; |
51 | 52 |
|
52 | 53 | // MARK: - I/O Utils - |
53 | 54 |
|
@@ -362,16 +363,20 @@ static void create_file (const char *path) { |
362 | 363 | exit(-2); |
363 | 364 | } |
364 | 365 |
|
365 | | - if (use_create_db) { |
| 366 | + if (create_db) { |
366 | 367 | write_line("CREATE DATABASE documentation.sqlite IF NOT EXISTS;", -1, 1); |
367 | 368 | } |
368 | 369 |
|
| 370 | + if (use_database) { |
| 371 | + write_line("USE DATABASE documentation.sqlite;", -1, 1); |
| 372 | + } |
| 373 | + |
369 | 374 | if (use_transaction) { |
370 | 375 | write_line("BEGIN TRANSACTION;", -1, 1); |
371 | 376 | } |
372 | 377 |
|
| 378 | + write_line("DROP TABLE IF EXITS documentation;", -1, 1); |
373 | 379 | write_line("CREATE VIRTUAL TABLE IF NOT EXISTS documentation USING fts5 (url, content);", -1, 1); |
374 | | - write_line("DELETE FROM documentation;", -1, 1); |
375 | 380 | } |
376 | 381 |
|
377 | 382 | static void create_output (const char *path) { |
@@ -545,11 +550,19 @@ int main (int argc, char * argv[]) { |
545 | 550 | { |
546 | 551 | .identifier = 'c', |
547 | 552 | .access_letters = "c", |
548 | | - .access_name = "add-create-database", |
| 553 | + .access_name = "create-database", |
549 | 554 | .value_name = NULL, |
550 | 555 | .description = "Add a CREATE DATABASE statement" |
551 | 556 | }, |
552 | 557 |
|
| 558 | + { |
| 559 | + .identifier = 'u', |
| 560 | + .access_letters = "u", |
| 561 | + .access_name = "use-database", |
| 562 | + .value_name = NULL, |
| 563 | + .description = "Add a USE DATABASE statement" |
| 564 | + }, |
| 565 | + |
553 | 566 | { |
554 | 567 | .identifier = 't', |
555 | 568 | .access_letters = "t", |
@@ -588,8 +601,9 @@ int main (int argc, char * argv[]) { |
588 | 601 | case 'm': strip_md_title = true; break; |
589 | 602 | case 'a': strip_astro_header = true; break; |
590 | 603 | case 't': use_transaction = true; break; |
| 604 | + case 'u': use_database = true; break; |
591 | 605 | case 's': json_mode = true; break; |
592 | | - case 'c': use_create_db = true; break; |
| 606 | + case 'c': create_db = true; break; |
593 | 607 |
|
594 | 608 | case 'h': |
595 | 609 | printf("Usage: docbuilder [OPTION]...\n"); |
|
0 commit comments