diff --git a/build.sh b/build.sh index 3f35d47..0f5a919 100755 --- a/build.sh +++ b/build.sh @@ -75,6 +75,7 @@ fi # Configure with CMake print_status "Configuring with CMake..." cmake .. -DCMAKE_BUILD_TYPE=Debug +#cmake .. -DCMAKE_BUILD_TYPE=Release # Build the project print_status "Building project..." diff --git a/src/autocomplete.cpp b/src/autocomplete.cpp index 641b4b1..8ee773f 100644 --- a/src/autocomplete.cpp +++ b/src/autocomplete.cpp @@ -67,18 +67,17 @@ void dropshell::autocomplete(const std::vector &args) std::string service_name = args[4]; if (cmd=="restore") { - std::set backups; - std::vector servers = dropshell::get_configured_servers(); - for (auto server : servers) - backups.merge(dropshell::list_backups(server.name, service_name)); - + std::set backups = dropshell::list_backups(service_name); for (auto backup : backups) std::cout << backup << std::endl; + return; } + return; // no more autocompletion possible - don't know what the argument is for. } - return; + // args>5 - no more autocompletion possible - don't know what the argument is for. + return; // catch-all. } void dropshell::autocomplete_list_commands() diff --git a/src/config.cpp b/src/config.cpp index 271f16a..396e6b1 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -60,7 +60,7 @@ void config::save_config() envmanager config_env(config_path); config_env.set_variable("local.config.directories", multi2string(mLocalConfigPaths)); - config_env.set_variable("local.backup.path", mLocalBackupPath); + config_env.set_variable("local.backup.directory", mLocalBackupPath); config_env.save(); } diff --git a/src/main.cpp b/src/main.cpp index 26ed8b7..cdbbed3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) { const std::vector & local_config_directories = cfg->get_local_config_directories(); std::cout << "Config directories: "; for (auto & dir : local_config_directories) - std::cout << "["<< dir << "] " << std::endl; + std::cout << "["<< dir << "] "; std::cout << std::endl; if (cmd == "server" || cmd == "servers" || cmd == "view" || cmd == "views" || cmd == "v") diff --git a/src/services.cpp b/src/services.cpp index 40e5548..a1d97a7 100644 --- a/src/services.cpp +++ b/src/services.cpp @@ -111,11 +111,11 @@ std::set get_used_commands(const std::string &server_name, const st return commands; } -std::set list_backups(const std::string &server_name, const std::string &service_name) +std::set list_backups(const std::string &service_name) { std::set backups; - if (server_name.empty() || service_name.empty()) + if (service_name.empty()) return backups; std::string backups_dir = get_local_backup_path(); @@ -126,7 +126,9 @@ std::set list_backups(const std::string &server_name, const std::st for (const auto& entry : fs::directory_iterator(backups_dir)) { if (fs::is_regular_file(entry) && entry.path().extension() == ".tgz") if (entry.path().filename().string().find(service_name) != std::string::npos) + { backups.insert(entry.path().filename().string()); + } } } return backups; diff --git a/src/services.hpp b/src/services.hpp index f37dbb8..5bdf7fa 100644 --- a/src/services.hpp +++ b/src/services.hpp @@ -18,8 +18,8 @@ namespace dropshell { ServiceInfo get_service_info(const std::string& server_name, const std::string& service_name); std::set get_used_commands(const std::string& server_name, const std::string& service_name); - // list all backups for a given server and service - std::set list_backups(const std::string& server_name, const std::string& service_name); + // list all backups for a given service (across all servers) + std::set list_backups(const std::string& service_name); bool create_service(const std::string& server_name, const std::string& template_name, const std::string& service_name); } // namespace dropshell