This commit is contained in:
Vaxry 2023-12-06 19:25:04 +00:00
parent 0ac8868724
commit 148ea16732
3 changed files with 19 additions and 1 deletions

View file

@ -367,7 +367,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
const auto REPOS = DataState::getAllRepositories(); const auto REPOS = DataState::getAllRepositories();
if (REPOS.size() < 1) { if (REPOS.size() < 1) {
std::cout << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " No repos to update."; std::cout << "\n" << std::string{Colors::RED} + "" + Colors::RESET + " No repos to update.\n";
return true; return true;
} }
@ -631,4 +631,17 @@ bool CPluginManager::loadUnloadPlugin(const std::string& path, bool load) {
execAndGet("hyprctl plugin unload " + path); execAndGet("hyprctl plugin unload " + path);
return true; return true;
}
void CPluginManager::listAllPlugins() {
const auto REPOS = DataState::getAllRepositories();
for (auto& r : REPOS) {
std::cout << std::string{Colors::RESET} + " → Repository " + r.name + ":\n";
for (auto& p : r.plugins) {
std::cout << std::string{Colors::RESET} + " │ Plugin " + p.name + "\n └─ enabled: " << (p.enabled ? Colors::GREEN : Colors::RED) << (p.enabled ? "true" : "false")
<< Colors::RESET << "\n";
}
}
} }

View file

@ -21,6 +21,8 @@ class CPluginManager {
bool updateHeaders(); bool updateHeaders();
bool updatePlugins(bool forceUpdateAll); bool updatePlugins(bool forceUpdateAll);
void listAllPlugins();
bool enablePlugin(const std::string& name); bool enablePlugin(const std::string& name);
bool disablePlugin(const std::string& name); bool disablePlugin(const std::string& name);
void ensurePluginsLoadState(); void ensurePluginsLoadState();

View file

@ -16,6 +16,7 @@ const std::string HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager
disable [name] Disable a plugin disable [name] Disable a plugin
update Check and update all plugins if needed update Check and update all plugins if needed
load Load hyprpm state. Ensure all enabled plugins are loaded. load Load hyprpm state. Ensure all enabled plugins are loaded.
list List all installed plugins
)#"; )#";
@ -79,6 +80,8 @@ int main(int argc, char** argv, char** envp) {
g_pPluginManager->ensurePluginsLoadState(); g_pPluginManager->ensurePluginsLoadState();
} else if (ARGS[1] == "load") { } else if (ARGS[1] == "load") {
g_pPluginManager->ensurePluginsLoadState(); g_pPluginManager->ensurePluginsLoadState();
} else if (ARGS[1] == "list") {
g_pPluginManager->listAllPlugins();
} else { } else {
std::cout << HELP; std::cout << HELP;
return 1; return 1;