Fix segfault 🤦
This commit is contained in:
@ -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.
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user