juk3n/fluffypublic Fork
⑂ c520d85
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.

added basic adding

juk3n committed 2024-06-12T19:17:56+02:00 Browse files
c520d85 parent: 4cdcc77
modified CMakeLists.txt +5 -4
@@ -1,11 +1,14 @@
11 cmake_minimum_required(VERSION 3.14)
2+set(CMAKE_CXX_STANDARD 20)
3+set(CMAKE_CXX_STANDARD_REQUIRED True)
4+project(fluffy LANGUAGES CXX VERSION 1.0.0)
25
36 include(FetchContent)
47
58 set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
69 FetchContent_Declare(ftxui
710 GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
8- GIT_TAG v5.0.0
11+ GIT_TAG v4.0.0
912 )
1013 FetchContent_MakeAvailable(ftxui)
1114 if(NOT ftxui_POPULATED)
@@ -13,10 +16,8 @@ if(NOT ftxui_POPULATED)
1316 add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
1417 endif()
1518
16-project(fluffy LANGUAGES CXX VERSION 1.0.0)
1719
18-set(CMAKE_CXX_STANDARD 20)
19-set(CMAKE_CXX_STANDARD_REQUIRED True)
20+
2021
2122
2223 find_package(SQLite3 REQUIRED)
@@ -1,11 +1,14 @@
1 cmake_minimum_required(VERSION 3.14)1 cmake_minimum_required(VERSION 3.14)
2+set(CMAKE_CXX_STANDARD 20)
3+set(CMAKE_CXX_STANDARD_REQUIRED True)
4+project(fluffy LANGUAGES CXX VERSION 1.0.0)
2 5
3 include(FetchContent)6 include(FetchContent)
4 7
5 set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)8 set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
6 FetchContent_Declare(ftxui9 FetchContent_Declare(ftxui
7 GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui10 GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
8- GIT_TAG v5.0.011+ GIT_TAG v4.0.0
9 )12 )
10 FetchContent_MakeAvailable(ftxui)13 FetchContent_MakeAvailable(ftxui)
11 if(NOT ftxui_POPULATED)14 if(NOT ftxui_POPULATED)
@@ -13,10 +16,8 @@ if(NOT ftxui_POPULATED)
13 add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)16 add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
14 endif()17 endif()
15 18
16-project(fluffy LANGUAGES CXX VERSION 1.0.0)
17 19
18-set(CMAKE_CXX_STANDARD 20)20+
19-set(CMAKE_CXX_STANDARD_REQUIRED True)
20 21
21 22
22 find_package(SQLite3 REQUIRED)23 find_package(SQLite3 REQUIRED)
modified src/main.cpp +29 -7
@@ -43,22 +43,20 @@ void execute_sql_command(sqlite3* database, std::string command) {
4343 }
4444 }
4545
46-void addGame(sqlite3* database, std::string name, std::string path) {
47- static int val = 1;
46+void addGame(sqlite3* database, int id, std::string name, std::string path) {
4847 std::string command = "INSERT INTO GAME (GAME_ID, GAME_NAME, GAME_PATH) VALUES (";
49- command += std::to_string(val) + ", '" + name + "', \"" + path + "\");";
50- val++;
48+ command += std::to_string(id) + ", '" + name + "', \"" + path + "\");";
5149 execute_sql_command(database, command);
5250 }
5351
5452 void initialize_database(sqlite3* database) {
5553 execute_sql_command(database, database_initialization_command);
56- addGame(database, "Devastating Fog", "");
57- addGame(database, "No Pirates Here!", "");
54+ addGame(database, 1, "Devastating Fog", "");
55+ addGame(database, 2, "No Pirates Here!", "");
5856 printMessage("Database Initialized");
5957 }
6058
61-int main() {
59+int main(int argc, char const *argv[]) {
6260 bool newCreation = not std::filesystem::exists("data.db");
6361
6462 char* messageError;
@@ -98,6 +96,30 @@ int main() {
9896 }
9997 sqlite3_finalize(stmt);
10098
99+ if (argc == 2) {
100+ return 0;
101+ }
102+
103+ if (argc == 4) {
104+ std::string command{ argv[1] };
105+ std::string gameName{ argv[2] };
106+ auto localPath = std::filesystem::path(argv[3]);
107+ std::string globalPath = std::filesystem::absolute(localPath).string();
108+
109+ std::string temp{};
110+ for (const auto a : globalPath) {
111+ if (a != ' ') {
112+ temp += a;
113+ }
114+ else {
115+ temp += "\' \'";
116+ }
117+ }
118+
119+ addGame(database, games.size() + 1, gameName, temp);
120+ return 0;
121+ }
122+
101123 int exit_id = games.size();
102124 int choice = 0;
103125 do {
@@ -43,22 +43,20 @@ void execute_sql_command(sqlite3* database, std::string command) {
43 }43 }
44 }44 }
45 45
46-void addGame(sqlite3* database, std::string name, std::string path) {46+void addGame(sqlite3* database, int id, std::string name, std::string path) {
47- static int val = 1;
48 std::string command = "INSERT INTO GAME (GAME_ID, GAME_NAME, GAME_PATH) VALUES (";47 std::string command = "INSERT INTO GAME (GAME_ID, GAME_NAME, GAME_PATH) VALUES (";
49- command += std::to_string(val) + ", '" + name + "', \"" + path + "\");";48+ command += std::to_string(id) + ", '" + name + "', \"" + path + "\");";
50- val++;
51 execute_sql_command(database, command);49 execute_sql_command(database, command);
52 }50 }
53 51
54 void initialize_database(sqlite3* database) {52 void initialize_database(sqlite3* database) {
55 execute_sql_command(database, database_initialization_command);53 execute_sql_command(database, database_initialization_command);
56- addGame(database, "Devastating Fog", "");54+ addGame(database, 1, "Devastating Fog", "");
57- addGame(database, "No Pirates Here!", "");55+ addGame(database, 2, "No Pirates Here!", "");
58 printMessage("Database Initialized"); 56 printMessage("Database Initialized");
59 }57 }
60 58
61-int main() {59+int main(int argc, char const *argv[]) {
62 bool newCreation = not std::filesystem::exists("data.db");60 bool newCreation = not std::filesystem::exists("data.db");
63 61
64 char* messageError;62 char* messageError;
@@ -98,6 +96,30 @@ int main() {
98 }96 }
99 sqlite3_finalize(stmt);97 sqlite3_finalize(stmt);
100 98
99+ if (argc == 2) {
100+ return 0;
101+ }
102+
103+ if (argc == 4) {
104+ std::string command{ argv[1] };
105+ std::string gameName{ argv[2] };
106+ auto localPath = std::filesystem::path(argv[3]);
107+ std::string globalPath = std::filesystem::absolute(localPath).string();
108+
109+ std::string temp{};
110+ for (const auto a : globalPath) {
111+ if (a != ' ') {
112+ temp += a;
113+ }
114+ else {
115+ temp += "\' \'";
116+ }
117+ }
118+
119+ addGame(database, games.size() + 1, gameName, temp);
120+ return 0;
121+ }
122+
101 int exit_id = games.size();123 int exit_id = games.size();
102 int choice = 0;124 int choice = 0;
103 do {125 do {