Compiles.

This commit is contained in:
Your Name 2025-04-23 21:57:06 +12:00
parent 9a3dd18525
commit f9b67ff4c0
6 changed files with 43 additions and 50 deletions

View File

@ -5,7 +5,7 @@
#include <boost/property_tree/ptree.hpp> #include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp> #include <boost/property_tree/ini_parser.hpp>
#include "config.hpp" #include "config.hpp"
#include "envmanager.hpp" #include "utils/envmanager.hpp"
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace pt = boost::property_tree; namespace pt = boost::property_tree;

View File

@ -1,4 +1,4 @@
#include "dropshell.hpp" #include "main.hpp"
#include <iostream> #include <iostream>
namespace dropshell { namespace dropshell {

View File

@ -51,36 +51,7 @@ std::vector<ServerInfo> get_configured_servers() {
return servers; return servers;
} }
void interactive_mode() {
interactive::fullscreen_window iw("DropShell Servers");
iw.set_input_text_display("Loading all servers' status...");
auto servers = get_configured_servers();
std::vector<std::string> server_names;
for (const auto& server : servers) {
server_names.push_back(server.name);
}
list_servers();
while (true) {
std::string server_name = iw.set_input_multiple_choice("Select a server", server_names);
if (server_name.empty())
{
iw.close();
return;
}
while (!server_name.empty()) {
iw.clear_display();
show_server_details(server_name);
server_name = iw.set_input_multiple_choice("Select a server", server_names, server_name);
}
iw.clear_display();
list_servers();
}
}
void list_servers() { void list_servers() {
auto servers = get_configured_servers(); auto servers = get_configured_servers();
@ -192,4 +163,39 @@ void show_server_details(const std::string& server_name) {
} // end of list services } // end of list services
} // end of show_server_details } // end of show_server_details
void interactive_mode() {
interactive::fullscreen_window iw("DropShell Servers");
iw.set_input_text_display("Loading all servers' status...");
auto servers = get_configured_servers();
std::vector<std::string> server_names;
for (const auto& server : servers) {
server_names.push_back(server.name);
}
list_servers();
while (true) {
std::string server_name = iw.set_input_multiple_choice("Select a server", server_names);
if (server_name.empty())
{
iw.close();
return;
}
while (!server_name.empty()) {
iw.clear_display();
show_server_details(server_name);
server_name = iw.set_input_multiple_choice("Select a server", server_names, server_name);
}
iw.clear_display();
list_servers();
}
}
} // namespace dropshell } // namespace dropshell

View File

@ -1,4 +1,4 @@
#include "dropshell.hpp" #include "main.hpp"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <chrono> #include <chrono>

View File

@ -1,6 +1,5 @@
#include "init_user_directory.hpp"
#include "templates.hpp" #include "templates.hpp"
#include "config.hpp" #include "config.hpp"
#include "utils/directories.hpp" #include "utils/directories.hpp"
#include <filesystem> #include <filesystem>
#include <iostream> #include <iostream>
@ -21,16 +20,7 @@ template_manager::~template_manager() {
bool template_manager::get_templates(std::vector<template_info>& templates) { bool template_manager::get_templates(std::vector<template_info>& templates) {
templates.clear(); templates.clear();
// System templates directory
const std::string system_templates_dir = get_local_system_templates_path();
// User templates directory (from config)
std::string user_templates_dir;
if (!get_user_directory(user_templates_dir)) {
return false;
}
user_templates_dir += "/usertemplates";
// Helper function to add templates from a directory // Helper function to add templates from a directory
auto add_templates_from_dir = [&templates](const std::string& dir_path) { auto add_templates_from_dir = [&templates](const std::string& dir_path) {
if (!std::filesystem::exists(dir_path)) { if (!std::filesystem::exists(dir_path)) {
@ -54,11 +44,8 @@ bool template_manager::get_templates(std::vector<template_info>& templates) {
} }
}; };
// First add system templates add_templates_from_dir(get_local_config_templates_path());
add_templates_from_dir(system_templates_dir); add_templates_from_dir(get_local_system_templates_path());
// Then add user templates (which will override system templates with same name)
add_templates_from_dir(user_templates_dir);
return true; return true;
} }

View File

@ -1,4 +1,4 @@
#include "dropshell.hpp" #include "main.hpp"
#include <iostream> #include <iostream>
namespace dropshell { namespace dropshell {