Skip to content

Commit

Permalink
feat: list practices in a table
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Jan 22, 2020
1 parent 1463309 commit 9d8a8f6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/commands/practices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down Expand Up @@ -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;
}

0 comments on commit 9d8a8f6

Please sign in to comment.