Skip to content

Commit 8b31df0

Browse files
committed
docbuilder v0.3
1 parent 503e393 commit 8b31df0

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

src/main.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
#define GENERATE_SQLITE_DATABASE 0
10-
#define DOCBUILDER_VERSION "0.2"
10+
#define DOCBUILDER_VERSION "0.3"
1111

1212
#include <stdio.h>
1313
#include <fcntl.h>
@@ -46,8 +46,9 @@ bool strip_jsx = false;
4646
bool strip_md_title = false;
4747
bool strip_astro_header = false;
4848
bool use_transaction = false;
49-
bool use_create_db = false;
5049
bool json_mode = false;
50+
bool use_database = false;
51+
bool create_db = false;
5152

5253
// MARK: - I/O Utils -
5354

@@ -362,16 +363,20 @@ static void create_file (const char *path) {
362363
exit(-2);
363364
}
364365

365-
if (use_create_db) {
366+
if (create_db) {
366367
write_line("CREATE DATABASE documentation.sqlite IF NOT EXISTS;", -1, 1);
367368
}
368369

370+
if (use_database) {
371+
write_line("USE DATABASE documentation.sqlite;", -1, 1);
372+
}
373+
369374
if (use_transaction) {
370375
write_line("BEGIN TRANSACTION;", -1, 1);
371376
}
372377

378+
write_line("DROP TABLE IF EXITS documentation;", -1, 1);
373379
write_line("CREATE VIRTUAL TABLE IF NOT EXISTS documentation USING fts5 (url, content);", -1, 1);
374-
write_line("DELETE FROM documentation;", -1, 1);
375380
}
376381

377382
static void create_output (const char *path) {
@@ -545,11 +550,19 @@ int main (int argc, char * argv[]) {
545550
{
546551
.identifier = 'c',
547552
.access_letters = "c",
548-
.access_name = "add-create-database",
553+
.access_name = "create-database",
549554
.value_name = NULL,
550555
.description = "Add a CREATE DATABASE statement"
551556
},
552557

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+
553566
{
554567
.identifier = 't',
555568
.access_letters = "t",
@@ -588,8 +601,9 @@ int main (int argc, char * argv[]) {
588601
case 'm': strip_md_title = true; break;
589602
case 'a': strip_astro_header = true; break;
590603
case 't': use_transaction = true; break;
604+
case 'u': use_database = true; break;
591605
case 's': json_mode = true; break;
592-
case 'c': use_create_db = true; break;
606+
case 'c': create_db = true; break;
593607

594608
case 'h':
595609
printf("Usage: docbuilder [OPTION]...\n");

0 commit comments

Comments
 (0)