1
0
mirror of https://github.com/bitwarden/cli synced 2026-02-06 03:03:14 +00:00
Files
cli/src/commands/encode.command.ts
Brandon Davis 47b5b9f950 feature/18-import (#19)
* fix #18

* Add locked check
2018-08-06 09:38:17 -04:00

19 lines
598 B
TypeScript

import * as program from 'commander';
import { Response } from '../models/response';
import { StringResponse } from '../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);
}
}