import { IChecker } from "./checker/interface";
import { Query } from "./reader/query";
import { IFormat } from "./formatter/interface";
import chalk from "chalk";
class Printer {
public verbosity: number;
public format: IFormat;
constructor(verbosity: number, format: IFormat) {
this.verbosity = verbosity;
this.format = format;
}
public printCheck(checker: IChecker, tokenised: Query, prefix: string) {
const result = checker.check(tokenised);
Eif (this.verbosity) {
const queryForPrint = JSON.stringify(tokenised.getContent());
const promptForPrint = `Linting Query: ${queryForPrint}`;
const tokenisedForPrint = JSON.stringify(tokenised, null, 4);
console.log(chalk.blue(promptForPrint));
console.log(chalk.yellow(`${tokenisedForPrint}`));
}
Iif (result.content) {
console.log(this.format.getMessage(prefix, result));
}
Eif (this.verbosity) {
console.log("\n-------------------------\n");
}
}
public warnAboutFileNotFound(file: string) {
console.log(`Can't open file ${file}. Does it exist?`);
}
}
export { Printer };
|