All checks were successful
Test / build (push) Successful in 7s
- Add a newline character at the end of the outputted file contents - This is so it follows POSIX convention #80 Reviewed-on: #196 Reviewed-by: VylpesTester <tester@vylpes.com> Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
25 lines
No EOL
750 B
TypeScript
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;
|
|
}
|
|
}
|
|
} |