Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x | import { defineCommand } from '../../lib/define-command.js';
import { styleText } from '../../lib/style-text.js';
import { Logger } from '../../logger.js';
import * as networkGroup from '../../models/ng.js';
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
export const ngCommand = defineCommand({
description: 'List Network Groups',
since: '3.12.0',
isExperimental: true,
featureFlag: 'ng',
options: {
org: orgaIdOrNameOption,
format: humanJsonOutputFormatOption,
},
args: [],
async handler(options) {
const { org, format } = options;
const ngs = await networkGroup.getAllNGs(org);
switch (format) {
case 'json': {
Logger.printJson(ngs);
break;
}
case 'human':
default: {
if (!ngs.length) {
Logger.println(`ℹ️ No Network Group found, create one with ${styleText('blue', 'clever ng create')} command`);
return;
}
const ngList = ngs.map(({ id, label, networkIp, members, peers }) => ({
ID: id,
Label: label,
'Network CIDR': networkIp,
Members: Object.keys(members).length,
Peers: Object.keys(peers).length,
}));
console.table(ngList);
}
}
},
});
|