juk3n/fluffypublic Fork
⑂ main
Commits
⬇ Clone ▾
git clone https://git.rickub.com/juk3n/fluffy.git
git clone ssh://git@rickub.com/juk3n/fluffy.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

7 removing the game with command fluffy rm game name #8

Merged@github-juk3n wants to merge 7-removing-the-game-with-command-fluffy-rm-game_name into main
Merged as be3af804bb9f.
1 file changed
modified src/main.cpp +12 -0
@@ -49,6 +49,12 @@ void addGame(sqlite3* database, int id, std::string name, std::string path) {
4949 execute_sql_command(database, command);
5050 }
5151
52+void removeGame(sqlite3* database, std::string name) {
53+ std::string command = "DELETE FROM GAME WHERE GAME_NAME=";
54+ command += "'" + name + "';";
55+ execute_sql_command(database, command);
56+}
57+
5258 void initialize_database(sqlite3* database) {
5359 execute_sql_command(database, database_initialization_command);
5460 addGame(database, 1, "Devastating Fog", "");
@@ -67,6 +73,12 @@ void handleCommand(int argc, char const *argv[], sqlite3* database) {
6773 }
6874 }
6975 break;
76+ case 3:
77+ command = argv[1];
78+ if (command == "rm") {
79+ std::string gameName{ argv[2] };
80+ removeGame(database, gameName);
81+ }
7082 case 4:
7183 command = argv[1];
7284 if (command == "add") {
@@ -49,6 +49,12 @@ void addGame(sqlite3* database, int id, std::string name, std::string path) {
49 execute_sql_command(database, command);49 execute_sql_command(database, command);
50 }50 }
51 51
52+void removeGame(sqlite3* database, std::string name) {
53+ std::string command = "DELETE FROM GAME WHERE GAME_NAME=";
54+ command += "'" + name + "';";
55+ execute_sql_command(database, command);
56+}
57+
52 void initialize_database(sqlite3* database) {58 void initialize_database(sqlite3* database) {
53 execute_sql_command(database, database_initialization_command);59 execute_sql_command(database, database_initialization_command);
54 addGame(database, 1, "Devastating Fog", "");60 addGame(database, 1, "Devastating Fog", "");
@@ -67,6 +73,12 @@ void handleCommand(int argc, char const *argv[], sqlite3* database) {
67 }73 }
68 }74 }
69 break;75 break;
76+ case 3:
77+ command = argv[1];
78+ if (command == "rm") {
79+ std::string gameName{ argv[2] };
80+ removeGame(database, gameName);
81+ }
70 case 4:82 case 4:
71 command = argv[1];83 command = argv[1];
72 if (command == "add") {84 if (command == "add") {