-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunLib.cpp
40 lines (37 loc) · 1.03 KB
/
RunLib.cpp
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
#include "LibraryApp.hpp"
#include <sqlite/connection.hpp>
#include <sqlite/execute.hpp>
#include <sqlite/query.hpp>
int main(int argc, char *argv[]) {
string config;
if (argc == 1) {
config = "m";
std::cout << "Your now using the in-memory library\n\n";
LibraryApp LibrarySim;
LibrarySim.runLibrary(config);
}
if (argc > 2) {
std::cout << "You cant have more than one argument\n\r";
return -1;
}
if (argc == 2) {
std::string files = "files";
std::string data = "data";
if (argv[1] == files) {
config = "f";
std::cout << "Your now using the in-files library\n\n";
}
if (argv[1] == data) {
sqlite::connection con("data/library.db");
sqlite::execute(
con,
"CREATE TABLE IF NOT EXISTS library(id INTEGER PRIMARY KEY, "
"name varchar(255) , author varchar(255) , pages int);",
true);
config = "d";
std::cout << "Your now using the in-databases library\n\n";
}
}
LibraryApp LibrarySim;
LibrarySim.runLibrary(config);
}