This commit is contained in:
Your Name
2025-04-26 09:09:20 +12:00
parent 9e6281c846
commit cf8a7db01d
9 changed files with 178 additions and 157 deletions

36
src/autocomplete.cpp Normal file
View File

@ -0,0 +1,36 @@
#include "autocomplete.hpp"
#include "servers.hpp"
#include "config.hpp"
#include <iostream>
void dropshell::autocomplete(const std::vector<std::string> &args)
{
// std::cerr << "[ "<<args.size()<<" ] : ";
// for (const auto& arg : args)
// std::cerr << arg << " ";
// std::cerr << std::endl;
if (args.size() < 3) // dropshell autocomplete ???
autocomplete_list_commands();
}
void dropshell::autocomplete_list_commands()
{
std::set<std::string> commands;
dropshell::get_all_used_commands(commands);
// add in commmands hard-coded and handled in main
commands.merge(std::set<std::string>{
"help","init" // these are always available.
});
if (dropshell::get_global_config()->is_config_set())
commands.merge(std::set<std::string>{
"server","templates","create-service","create-template","create-server","edit","ssh",
"view" // only if we have a config.
});
for (const auto& command : commands) {
std::cout << command << std::endl;
}
}