busted
This commit is contained in:
36
src/autocomplete.cpp
Normal file
36
src/autocomplete.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user