UNPKG

@gmb/bitmark-cli

Version:
69 lines 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const bitmark_parser_generator_1 = require("@gmb/bitmark-parser-generator"); const core_1 = require("@oclif/core"); const bitmarkTool = new bitmark_parser_generator_1.BitmarkParserGenerator(); /** * Breakscape command */ // eslint-disable-next-line arca/no-default-export class Breakscape extends core_1.Command { async run() { const { args, flags } = await this.parse(Breakscape); const { input } = args; const { output, append } = flags; let dataIn; if (input != undefined) { dataIn = input; } else { // Read from stdin dataIn = await this.readStream(process.stdin); } // Bitmark tool text conversion const res = bitmarkTool.breakscapeText(dataIn, { outputFile: output, fileOptions: { append, }, }); if (!output) { console.log(res); } } async readStream(stream) { const chunks = []; for await (const chunk of stream) chunks.push(chunk); return Buffer.concat(chunks).toString('utf8'); } } Breakscape.description = 'Breakscape text'; Breakscape.examples = [ "<%= config.bin %> <%= command.id %> '[.article] Hello World'", '<%= config.bin %> <%= command.id %> input.txt -o output.txt', ]; Breakscape.flags = { // General // File output output: core_1.Flags.file({ helpGroup: 'File output', char: 'o', description: 'output file. If not specified, output will be to <stdout>', helpValue: 'FILE', }), append: core_1.Flags.boolean({ helpGroup: 'File output', char: 'a', description: 'append to the output file (default is to overwrite)', dependsOn: ['output'], }), }; Breakscape.args = { input: core_1.Args.string({ description: 'file to read, or text. If not specified, input will be from <stdin>', required: false, }), }; exports.default = Breakscape; //# sourceMappingURL=breakscape.js.map