From 148ea1673272c2a34bcfe0437fecf09844a03a53 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Wed, 6 Dec 2023 19:25:04 +0000 Subject: [PATCH] add list --- hyprpm/src/core/PluginManager.cpp | 15 ++++++++++++++- hyprpm/src/core/PluginManager.hpp | 2 ++ hyprpm/src/main.cpp | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp index b50fb040..af946785 100644 --- a/hyprpm/src/core/PluginManager.cpp +++ b/hyprpm/src/core/PluginManager.cpp @@ -367,7 +367,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) { const auto REPOS = DataState::getAllRepositories(); 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; } @@ -631,4 +631,17 @@ bool CPluginManager::loadUnloadPlugin(const std::string& path, bool load) { execAndGet("hyprctl plugin unload " + path); 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"; + } + } } \ No newline at end of file diff --git a/hyprpm/src/core/PluginManager.hpp b/hyprpm/src/core/PluginManager.hpp index f344c59d..5c587c8a 100644 --- a/hyprpm/src/core/PluginManager.hpp +++ b/hyprpm/src/core/PluginManager.hpp @@ -21,6 +21,8 @@ class CPluginManager { bool updateHeaders(); bool updatePlugins(bool forceUpdateAll); + void listAllPlugins(); + bool enablePlugin(const std::string& name); bool disablePlugin(const std::string& name); void ensurePluginsLoadState(); diff --git a/hyprpm/src/main.cpp b/hyprpm/src/main.cpp index 4e519d53..02131df3 100644 --- a/hyprpm/src/main.cpp +++ b/hyprpm/src/main.cpp @@ -16,6 +16,7 @@ const std::string HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager ┣ disable [name] → Disable a plugin ┣ update → Check and update all plugins if needed ┣ 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(); } else if (ARGS[1] == "load") { g_pPluginManager->ensurePluginsLoadState(); + } else if (ARGS[1] == "list") { + g_pPluginManager->listAllPlugins(); } else { std::cout << HELP; return 1;