mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 16:05:58 +01:00
hyprctl: add json output on hyprctl -j plugins list (#8480)
--------- Co-authored-by: Руслан Новокшонов <r.novokshonov@vk.team>
This commit is contained in:
parent
9d37b1b073
commit
af83c82513
1 changed files with 30 additions and 7 deletions
|
@ -1472,17 +1472,40 @@ std::string dispatchPlugin(eHyprCtlOutputFormat format, std::string request) {
|
||||||
|
|
||||||
g_pPluginSystem->unloadPlugin(PLUGIN);
|
g_pPluginSystem->unloadPlugin(PLUGIN);
|
||||||
} else if (OPERATION == "list") {
|
} else if (OPERATION == "list") {
|
||||||
const auto PLUGINS = g_pPluginSystem->getAllPlugins();
|
const auto PLUGINS = g_pPluginSystem->getAllPlugins();
|
||||||
|
std::string result = "";
|
||||||
|
|
||||||
if (PLUGINS.size() == 0)
|
if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
|
||||||
return "no plugins loaded";
|
result += "[";
|
||||||
|
|
||||||
std::string list = "";
|
if (PLUGINS.size() == 0)
|
||||||
for (auto const& p : PLUGINS) {
|
return "[]";
|
||||||
list += std::format("\nPlugin {} by {}:\n\tHandle: {:x}\n\tVersion: {}\n\tDescription: {}\n", p->name, p->author, (uintptr_t)p->m_pHandle, p->version, p->description);
|
|
||||||
|
for (auto const& p : PLUGINS) {
|
||||||
|
result += std::format(
|
||||||
|
R"#(
|
||||||
|
{{
|
||||||
|
"name": "{}",
|
||||||
|
"author": "{}",
|
||||||
|
"handle": "{:x}",
|
||||||
|
"version": "{}",
|
||||||
|
"description": "{}"
|
||||||
|
}},)#",
|
||||||
|
escapeJSONStrings(p->name), escapeJSONStrings(p->author), (uintptr_t)p->m_pHandle, escapeJSONStrings(p->version), escapeJSONStrings(p->description));
|
||||||
|
}
|
||||||
|
trimTrailingComma(result);
|
||||||
|
result += "]";
|
||||||
|
} else {
|
||||||
|
if (PLUGINS.size() == 0)
|
||||||
|
return "no plugins loaded";
|
||||||
|
|
||||||
|
for (auto const& p : PLUGINS) {
|
||||||
|
result +=
|
||||||
|
std::format("\nPlugin {} by {}:\n\tHandle: {:x}\n\tVersion: {}\n\tDescription: {}\n", p->name, p->author, (uintptr_t)p->m_pHandle, p->version, p->description);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
return "unknown opt";
|
return "unknown opt";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue