summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-28 23:23:57 +0800
committerruki <[email protected]>2025-12-28 23:35:13 +0800
commit605f54ed2bd1be6c9a41df966aab47721b5f2c86 (patch)
tree955fbf39b56b280ef8513dd31aec15226b5b091c
parent7ee27a5e5a58b4d8a51ec0d2c0fc153239cb6722 (diff)
show envs with json
-rw-r--r--xmake/plugins/show/lists/envs.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/xmake/plugins/show/lists/envs.lua b/xmake/plugins/show/lists/envs.lua
index bb2bce8e3..bedbef873 100644
--- a/xmake/plugins/show/lists/envs.lua
+++ b/xmake/plugins/show/lists/envs.lua
@@ -20,6 +20,8 @@
-- imports
import("core.base.text")
+import("core.base.json")
+import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.project.project")
@@ -43,6 +45,16 @@ function main()
XMAKE_BINARY_REPO = {"Set the official package pre-compiled repository url.", os.getenv("XMAKE_BINARY_REPO")},
XMAKE_THEME = {"Set theme.", os.getenv("XMAKE_THEME") or global.get("theme")},
XMAKE_STATS = {"Enable or disable user statistics.", os.getenv("XMAKE_STATS")}}
+
+ if option.get("json") then
+ local list = {}
+ for name, env in pairs(envs) do
+ table.insert(list, {name = name, description = env[1], value = env[2]})
+ end
+ print(json.encode(list))
+ return
+ end
+
local width = 24
for name, env in pairs(envs) do
cprint("${color.dump.string}%s${clear}%s%s", name, (" "):rep(width - #name), env[1])