Tidy config file format.
This commit is contained in:
@ -1,11 +1,14 @@
|
||||
#include "autocomplete.hpp"
|
||||
#include "servers.hpp"
|
||||
#include "config.hpp"
|
||||
#include "templates.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
void dropshell::autocomplete(const std::vector<std::string> &args)
|
||||
{
|
||||
auto cfg = dropshell::get_global_config();
|
||||
// std::cerr << "[ "<<args.size()<<" ] : ";
|
||||
// for (const auto& arg : args)
|
||||
// std::cerr << arg << " ";
|
||||
@ -13,6 +16,49 @@ void dropshell::autocomplete(const std::vector<std::string> &args)
|
||||
|
||||
if (args.size() < 3) // dropshell autocomplete ???
|
||||
autocomplete_list_commands();
|
||||
|
||||
std::string cmd = args[2];
|
||||
|
||||
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;
|
||||
|
||||
if (!cfg->is_config_set())
|
||||
return; // can't help without working config.
|
||||
|
||||
if (args.size()==3) // we have the command but nothing else. dropshell autocomplete command <server>
|
||||
{
|
||||
auto servers = dropshell::get_configured_servers();
|
||||
for (const auto& server : servers)
|
||||
std::cout << server.name << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.size()==4) // we have the command and the server. dropshell autocomplete command server <service>
|
||||
{
|
||||
std::string server = args[3];
|
||||
|
||||
if (cmd=="create-service")
|
||||
{ // create-service <server> <template> <service>
|
||||
std::vector<template_info> templates;
|
||||
get_templates(templates);
|
||||
for (const auto& t : templates)
|
||||
std::cout << t.name << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
auto services = dropshell::get_server_services_info(server);
|
||||
for (const auto& service : services)
|
||||
std::cout << service.service_name << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.size()==5) // we have the command and the server and the service. dropshell autocomplete command server service_name <command?>
|
||||
{
|
||||
return; // no more autocompletion possible - don't know what the argument is for.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void dropshell::autocomplete_list_commands()
|
||||
|
Reference in New Issue
Block a user