From d782aae00f82bd160b0fc5c0cdac1ba27ae8ade1 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 20 Apr 2026 22:37:26 +0800 Subject: add --format --- xmake/plugins/show/info/basic.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'xmake/plugins/show/info/basic.lua') diff --git a/xmake/plugins/show/info/basic.lua b/xmake/plugins/show/info/basic.lua index 4ad14fe98..8a29dc2c0 100644 --- a/xmake/plugins/show/info/basic.lua +++ b/xmake/plugins/show/info/basic.lua @@ -128,8 +128,13 @@ function main() config.load() + -- support --format=json, with --json/--pretty backward compatibility + local format = option.get("format") or "plain" + if format == "plain" and option.get("json") then + format = "json" + end local opt = { - json = option.get("json"), + json = format == "json", pretty = option.get("pretty") } local result = opt.json and {} or nil @@ -138,9 +143,9 @@ function main() result = _show_project_info(opt, result) if opt.json then - local json_opt - if opt.pretty then - json_opt = {pretty = true, orderkeys = true} + local json_opt = {pretty = true, orderkeys = true} + if option.get("json") and not option.get("pretty") then + json_opt = nil end print(json.encode(result or {}, json_opt)) end -- cgit v1.3.1