diff --git a/src/commands/practices.ts b/src/commands/practices.ts index e74a2f72c..816c73faa 100644 --- a/src/commands/practices.ts +++ b/src/commands/practices.ts @@ -2,6 +2,7 @@ import { Command, flags } from '@oclif/command'; import { createRootContainer } from '../inversify.config'; import { Scanner } from '../scanner'; import { PracticeImpact } from '../model'; +import { ReporterData } from '../reporters/ReporterData'; export default class Practices extends Command { static description = 'List all practices id with name and impact.'; @@ -32,24 +33,24 @@ export default class Practices extends Command { const practices = await scanner.listPractices(); const practicesToReport: PracticeToReport[] = []; practices.forEach((practice) => { - const practiceId: string = practice.getMetadata().id; practicesToReport.push({ - [practiceId]: { name: practice.getMetadata().name, impact: practice.getMetadata().impact }, + id: practice.getMetadata().id, + name: practice.getMetadata().name, + impact: practice.getMetadata().impact, }); }); if (flags.json) { // print practices in JSON format console.log(JSON.stringify(practicesToReport, null, 2)); } else { - console.log(practicesToReport); + console.log(ReporterData.table(['PRACTICE ID', 'PRACTICE NAME', 'PRACTICE IMPACT'], practicesToReport)); } process.exit(0); } } interface PracticeToReport { - [id: string]: { - name: string; - impact: PracticeImpact; - }; + id: string; + name: string; + impact: PracticeImpact; }