Skip to content

Commit

Permalink
Add initial CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarWatcher committed Sep 2, 2024
1 parent 82f54df commit bf71605
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.28)
project(hazel)
project(hazel VERSION 0.0.1)

set (CMAKE_CXX_STANDARD 20)

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ target_link_libraries(hazelsrc
${UUID_LIB}
OpenSSL::Crypto
SQLiteCpp
CLI11::CLI11
)
target_link_libraries(hazel hazelsrc)

Expand Down
22 changes: 21 additions & 1 deletion src/hazel/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@
#include "spdlog/spdlog.h"
#include "spdlog/cfg/env.h"

int main() {
#include "CLI/CLI.hpp"
#include <filesystem>

int main(int argc, char** argv) {
#ifdef HAZEL_DEBUG
spdlog::set_level(spdlog::level::debug);
#else
spdlog::cfg::load_env_levels();
#endif
CLI::App app{
"Homelab metaserver"
};

std::filesystem::path configDir =
#ifdef HAZEL_DEBUG
"./data/";
#else
"/opt/hazel/data/";
#endif

app.add_option("-d,--data-dir", configDir, "Where to source data and config from. This is where the database goes, and where scripts go");

CLI11_PARSE(app, argc, argv);

std::filesystem::create_directories(configDir);

hazel::HazelCore::getInstance().init();
}
1 change: 0 additions & 1 deletion src/hazel/server/Hazel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ void HazelCore::bootstrapDatabase() {
db.initDatabase();
}


void HazelCore::prepareHandlers() {
#ifdef HAZEL_DEBUG
if (std::filesystem::exists("www-debug")) {
Expand Down

0 comments on commit bf71605

Please sign in to comment.