-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (41 loc) · 1.07 KB
/
Copy pathmain.cpp
File metadata and controls
47 lines (41 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include "control.h"
using namespace std;
int main(int argc, char* argv[]) {
if (argc < 2) {
cout << "Usage: ./main [migrate <directory>|run|down]" << endl;
return 1;
}
string command = argv[1];
sqlite3* db = initDB("test");
if (!db) {
return 1;
}
if (command == "migrate" && argc > 2) {
string migpath = argv[2];
string err = migrate(migpath, db);
if (!err.empty()) {
cerr << err << endl;
closeDB(db);
return 1;
}
} else if (command == "run") {
// Run the program
cout << "Running the program..." << endl;
index(db); // Start the application
} else if (command == "down") {
string migpath = "migrations/down";
string err = migrate(migpath, db);
if (!err.empty()) {
cerr << err << endl;
closeDB(db);
return 1;
}
} else {
cout << "Invalid command." << endl;
closeDB(db);
return 1;
}
closeDB(db);
return 0;
}