👷 add function to dump settings

This commit is contained in:
Vladislav Nepogodin 2023-04-03 03:23:37 +04:00
parent 1f0cfb9b10
commit dcad598b02
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
2 changed files with 13 additions and 0 deletions

View File

@ -271,6 +271,18 @@ void dump_to_log(const std::string& data) noexcept {
spdlog::info("[DUMP_TO_LOG] :=\n{}", data);
}
void dump_settings_to_log() noexcept {
auto* config_instance = Config::instance();
auto& config_data = config_instance->data();
std::string out{};
for(const auto& [key, value] : config_data) {
const auto& value_formatted = std::visit([](auto&& arg) -> std::string { return fmt::format("{}", arg); }, value);
out += fmt::format("Option: [{}], Value: [{}]\n", key, value_formatted);
}
spdlog::info("Settings:\n{}", out);
}
bool prompt_char(const char* prompt, const char* color, char* read) noexcept {
fmt::print("{}{}{}\n", color, prompt, RESET);

View File

@ -68,6 +68,7 @@ auto exec(const std::string_view& command, const bool& interactive = false) noex
[[nodiscard]] auto read_whole_file(const std::string_view& filepath) noexcept -> std::string;
bool write_to_file(const std::string_view& data, const std::string_view& filepath) noexcept;
void dump_to_log(const std::string& data) noexcept;
void dump_settings_to_log() noexcept;
[[nodiscard]] bool check_root() noexcept;
void id_system() noexcept;
[[nodiscard]] bool handle_connection() noexcept;