UNPKG

@gmb/bitmark-cli

Version:
69 lines 2.16 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 Unbreakscape extends core_1.Command { async run() { const { args, flags } = await this.parse(Unbreakscape); 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.unbreakscapeText(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'); } } Unbreakscape.description = 'Unbreakscape text'; Unbreakscape.examples = [ "<%= config.bin %> <%= command.id %> '[^.article] Hello World'", '<%= config.bin %> <%= command.id %> input.txt -o output.txt', ]; Unbreakscape.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'], }), }; Unbreakscape.args = { input: core_1.Args.string({ description: 'file to read, or text. If not specified, input will be from <stdin>', required: false, }), }; exports.default = Unbreakscape; //# sourceMappingURL=unbreakscape.js.map