random-bunny/src/helpers/cliHelper.ts
Ethan Lane adb8a00c1f
All checks were successful
Test / build (push) Successful in 8s
Add a newline character to the output of a file
2024-07-22 18:13:59 +01:00

25 lines
No EOL
750 B
TypeScript

import { writeFileSync } from "fs";
import ICliOptions from "../contracts/ICliOptions";
import IReturnResult from "../contracts/IReturnResult";
import OutputHelper from "./outputHelper";
export default class CliHelper {
public static Endpoint(response: IReturnResult, options: ICliOptions): number {
if (response.IsSuccess) {
const output = OutputHelper.GenerateOutput(response, options);
if (options.o) {
writeFileSync(options.o, `${output}\n`);
} else {
console.log(output);
}
return 0;
} else {
const error = response.Error!;
console.error(error.Message, error.Code);
return 1;
}
}
}