Fix segfault 🤦

This commit is contained in:
Your Name
2025-04-26 18:05:18 +12:00
parent 65fad9e1b0
commit 4953d4988d
4 changed files with 24 additions and 7 deletions

View File

@ -2,6 +2,8 @@
#include "servers.hpp"
#include "config.hpp"
#include "templates.hpp"
#include "services.hpp"
#include "servers.hpp"
#include <algorithm>
#include <iostream>
@ -15,10 +17,15 @@ void dropshell::autocomplete(const std::vector<std::string> &args)
// std::cerr << std::endl;
if (args.size() < 3) // dropshell autocomplete ???
{
autocomplete_list_commands();
return;
}
std::string cmd = args[2];
// std::cout<<" cmd = ["<<cmd<<"]"<<std::endl;
std::string noargcmds[] = {"templates","autocomplete_list_servers","autocomplete_list_services","autocomplete_list_commands"};
if (std::find(std::begin(noargcmds), std::end(noargcmds), cmd) != std::end(noargcmds))
return;
@ -54,7 +61,18 @@ void dropshell::autocomplete(const std::vector<std::string> &args)
}
if (args.size()==5) // we have the command and the server and the service. dropshell autocomplete command server service_name <command?>
{
{
std::string service_name = args[4];
if (cmd=="restore")
{
std::set<std::string> backups;
std::vector<dropshell::ServerInfo> servers = dropshell::get_configured_servers();
for (auto server : servers)
backups.merge(dropshell::list_backups(server.name, service_name));
for (auto backup : backups)
std::cout << backup << std::endl;
}
return; // no more autocompletion possible - don't know what the argument is for.
}