added feature to add records

develop
tastytea 2018-08-30 16:04:11 +02:00
parent 1f15ef0253
commit 2bd6eeae40
No known key found for this signature in database
GPG Key ID: CFC39497F1B26E07
2 changed files with 50 additions and 14 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7) cmake_minimum_required (VERSION 3.7)
project (whyblocked project (whyblocked
VERSION 0.2.0 VERSION 0.3.0
LANGUAGES CXX LANGUAGES CXX
) )

View File

@ -45,7 +45,6 @@ int main(int argc, char *argv[])
try try
{ {
sqlite::connection con(get_filepath()); sqlite::connection con(get_filepath());
string answer;
bool keeprunning = true; bool keeprunning = true;
cout << "This is whyblock " << global::version << ".\n"; cout << "This is whyblock " << global::version << ".\n";
@ -53,6 +52,7 @@ int main(int argc, char *argv[])
cout << "Type quit or q to quit the program.\n"; cout << "Type quit or q to quit the program.\n";
while (keeprunning) while (keeprunning)
{ {
string answer = "";
cout << ": "; cout << ": ";
cin >> answer; cin >> answer;
switch (answer[0]) switch (answer[0])
@ -60,7 +60,54 @@ int main(int argc, char *argv[])
case 'a': case 'a':
case 'A': case 'A':
{ {
cout << "ADD\n"; string user, reason;
int blocked = -1;
cout << "User or Instance: ";
cin >> user;
while (blocked == -1)
{
cout << "Blocked(b) or silenced(s): ";
cin >> answer;
if (answer[0] == 'b' || answer[0] == 'B')
{
blocked = 1;
}
else if (answer[0] == 's' || answer[0] == 'S')
{
blocked = 0;
}
}
cout << "Reason: ";
cin.ignore();
std::getline(cin, reason, '\n');
sqlite::execute ins(con, "INSERT INTO blocks VALUES(?, ?, ?);");
ins % user % blocked % reason;
ins();
while (true)
{
cout << "Add receipt? [y/n] ";
cin >> answer;
if (answer[0] == 'y' || answer[0] == 'Y')
{
string url;
cout << "URL: ";
cin >> url;
sqlite::execute ins(con, "INSERT INTO urls VALUES(?, ?);");
ins % user % url;
ins();
}
else if (answer[0] == 'n' || answer[0] == 'N')
{
break;
}
else
{
continue;
}
}
break; break;
} }
case 'r': case 'r':
@ -132,17 +179,6 @@ int main(int argc, char *argv[])
cout << "Response not understood.\n"; cout << "Response not understood.\n";
} }
} }
// sqlite::execute ins(con, "INSERT INTO TEST VALUES(?, ?, ?);");
// ins % sqlite::nil % "Hello";
// ins();
// sqlite::query q(con, "SELECT * FROM blocks;");
// boost::shared_ptr<sqlite::result> result = q.get_result();
// while(result->next_row())
// {
// std::cout << "ID: " << result->get_int(0) << "\n"
// << "Name: " << result->get_string(1) << std::endl;
// }
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {