mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-09 05:57:40 +02:00
19 lines
612 B
TypeScript
19 lines
612 B
TypeScript
import * as program from 'commander';
|
|
|
|
import { Response } from 'jslib/cli/models/response';
|
|
import { StringResponse } from 'jslib/cli/models/response/stringResponse';
|
|
|
|
import { CliUtils } from '../utils';
|
|
|
|
export class EncodeCommand {
|
|
async run(cmd: program.Command): Promise<Response> {
|
|
if (process.stdin.isTTY) {
|
|
return Response.badRequest('No stdin was piped in.');
|
|
}
|
|
const input = await CliUtils.readStdin();
|
|
const b64 = Buffer.from(input, 'utf8').toString('base64');
|
|
const res = new StringResponse(b64);
|
|
return Response.success(res);
|
|
}
|
|
}
|