iter(g172): 列表命令支持 JSON 输出

This commit is contained in:
HIsheR
2026-10-26 16:19:32 +08:00
parent a071cb041e
commit 250601dc78
6 changed files with 12 additions and 8 deletions
+4
View File
@@ -125,6 +125,10 @@ function loadIndex() {
function cmdList(args = []) {
const { packages } = loadIndex();
if (!packages.length) return console.log('(no packages indexed)');
if (args.includes('--json')) { // 机器可读:包 + 组件 id 清单,脚本 / Agent 不必解析文本
console.log(JSON.stringify(packages.map((p) => ({ name: p.name, version: p.version, type: p.type, description: p.description, components: (p.docs?.components ?? []).map((c) => c.id) })), null, 2));
return;
}
if (args.includes('--components')) {
let total = 0;
for (const p of packages) {