From bcc648d04c6d896fde3951190584e61ef46e223c Mon Sep 17 00:00:00 2001 From: Evgenij Titarenko Date: Mon, 25 Aug 2025 12:00:22 +0300 Subject: [PATCH] Initial commit --- .idea/.gitignore | 8 ++++ .idea/.name | 1 + .idea/editor.xml | 102 ++++++++++++++++++++++++++++++++++++++++ .idea/local-meme-db.iml | 2 + .idea/misc.xml | 7 +++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ CMakeLists.txt | 19 ++++++++ src/core/commands.cpp | 6 +++ src/core/commands.h | 26 ++++++++++ src/main.cpp | 54 +++++++++++++++++++++ 11 files changed, 239 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/editor.xml create mode 100644 .idea/local-meme-db.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 CMakeLists.txt create mode 100644 src/core/commands.cpp create mode 100644 src/core/commands.h create mode 100644 src/main.cpp diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..f6df7fd --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +local_meme_db \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..e54e87a --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,102 @@ + + + + + \ No newline at end of file diff --git a/.idea/local-meme-db.iml b/.idea/local-meme-db.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/local-meme-db.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0b76fe5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..98114fb --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a071dae --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.31) +project(local_meme_db) + +set(CMAKE_CXX_STANDARD 23) + +include(FetchContent) +FetchContent_Declare( + argparse + GIT_REPOSITORY https://github.com/p-ranav/argparse.git +) +FetchContent_MakeAvailable(argparse) + + +add_executable(local_meme_db src/main.cpp + src/core/commands.cpp + src/core/commands.h +) + +target_link_libraries(local_meme_db argparse) \ No newline at end of file diff --git a/src/core/commands.cpp b/src/core/commands.cpp new file mode 100644 index 0000000..1c97020 --- /dev/null +++ b/src/core/commands.cpp @@ -0,0 +1,6 @@ +// +// Created by frundle on 24.08.2025. +// + +#include "commands.h" + diff --git a/src/core/commands.h b/src/core/commands.h new file mode 100644 index 0000000..98ed907 --- /dev/null +++ b/src/core/commands.h @@ -0,0 +1,26 @@ +#ifndef COMMANDS_H +#define COMMANDS_H +#include +#include + +enum Commands { + INVALID, + ADD, + REMOVE, + LS, + SEARCH, + GET, + VALIDATE +}; + +inline std::unordered_map mapStringToCommand +{ + {"add", Commands::ADD}, + {"remove", Commands::REMOVE}, + {"ls", Commands::LS}, + {"search", Commands::SEARCH}, + {"get", Commands::GET}, + {"validate", Commands::VALIDATE} +}; + +#endif //COMMANDS_H diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..3c85efa --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,54 @@ +#include +#include +#include "core/commands.h" + + + +int main(const int argc, char *argv[]) { + + argparse::ArgumentParser program("local-meme-db"); + program.add_argument("command"); + try { + program.parse_args(argc, argv); + } + catch (const std::exception &e) { + std::cerr << e.what() << std::endl; + std::cerr << program; + std::exit(EXIT_FAILURE); + } + + auto commandString = program.get("command"); + const auto command = mapStringToCommand.contains(commandString) ? mapStringToCommand.at(commandString) : INVALID; + switch (command) { + case ADD: { + //TODO: Реализовать метод добавления файла + break; + } + case REMOVE: { + //TODO: Реализовать метод удаления файла + break; + } + case LS: { + //TODO: Реализовать метод вывода всех файлов + break; + } + case SEARCH: { + //TODO: Реализовать метод поиска файла по тегам/описанию(?) + break; + } + case GET: { + //TODO: Реализовать метод получения файла + break; + } + case VALIDATE: { + //TODO: Реализовать метод проверки целостности + break; + } + default: { + std::cout << "No such command" << std::endl; + std::exit(EXIT_FAILURE); + } + } + std::cout << command << std::endl; + return 0; +} \ No newline at end of file