2018-05-14 23:13:57 +02:00
|
|
|
import * as program from 'commander';
|
|
|
|
|
2021-06-07 19:25:55 +02:00
|
|
|
import { Response } from 'jslib-node/cli/models/response';
|
|
|
|
import { StringResponse } from 'jslib-node/cli/models/response/stringResponse';
|
2018-05-14 23:13:57 +02:00
|
|
|
|
2018-05-17 04:40:48 +02:00
|
|
|
import { CliUtils } from '../utils';
|
|
|
|
|
2018-05-14 23:13:57 +02:00
|
|
|
export class EncodeCommand {
|
2021-02-03 18:44:33 +01:00
|
|
|
async run(): Promise<Response> {
|
2018-05-17 04:40:48 +02:00
|
|
|
if (process.stdin.isTTY) {
|
|
|
|
return Response.badRequest('No stdin was piped in.');
|
2018-05-14 23:13:57 +02:00
|
|
|
}
|
2018-05-17 04:40:48 +02:00
|
|
|
const input = await CliUtils.readStdin();
|
2018-08-06 15:38:17 +02:00
|
|
|
const b64 = Buffer.from(input, 'utf8').toString('base64');
|
2018-05-17 04:40:48 +02:00
|
|
|
const res = new StringResponse(b64);
|
|
|
|
return Response.success(res);
|
2018-05-14 23:13:57 +02:00
|
|
|
}
|
|
|
|
}
|