iter(g172): 列表命令支持 JSON 输出
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user