...
This commit is contained in:
@ -63,17 +63,6 @@ std::vector<std::string> autocomplete_list_commands() {
|
||||
std::vector<std::string> commands;
|
||||
std::set<std::string> unique_commands; // To ensure deduplication
|
||||
|
||||
// System templates directory
|
||||
const std::string system_templates_dir = "/opt/dropshell/templates";
|
||||
|
||||
// User templates directory
|
||||
std::string user_templates_dir;
|
||||
if (!get_user_directory(user_templates_dir)) {
|
||||
std::cerr << "Error: User directory not set" << std::endl;
|
||||
return commands;
|
||||
}
|
||||
user_templates_dir += "/usertemplates";
|
||||
|
||||
// Helper function to add commands from a directory
|
||||
auto add_commands_from_dir = [&unique_commands](const std::string& dir_path) {
|
||||
if (!fs::exists(dir_path)) {
|
||||
@ -96,11 +85,17 @@ std::vector<std::string> autocomplete_list_commands() {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Add commands from both template locations
|
||||
|
||||
// System templates directory
|
||||
const std::string system_templates_dir = "/opt/dropshell/templates";
|
||||
add_commands_from_dir(system_templates_dir);
|
||||
add_commands_from_dir(user_templates_dir);
|
||||
|
||||
|
||||
std::string user_templates_dir;
|
||||
if (get_user_directory(user_templates_dir)) {
|
||||
// User templates directory
|
||||
user_templates_dir += "/usertemplates";
|
||||
add_commands_from_dir(user_templates_dir);
|
||||
}
|
||||
// Convert set to vector for return
|
||||
commands.assign(unique_commands.begin(), unique_commands.end());
|
||||
return commands;
|
||||
|
Reference in New Issue
Block a user