UNPKG

@e-invoice-eu/cli

Version:

Generate e-invoices (E-Rechnung in German) conforming to EN16931 (Factur-X/ZUGFeRD, UBL, CII, XRechnung aka X-Rechnung) from LibreOffice Calc/Excel data or JSON.

101 lines 3.44 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Schema = void 0; const core_1 = require("@e-invoice-eu/core"); const runtime_1 = require("@esgettext/runtime"); const fs = __importStar(require("fs/promises")); const optspec_1 = require("../optspec"); const package_1 = require("../package"); const safe_stdout_write_1 = require("../safe-stdout-write"); const gtx = runtime_1.Textdomain.getInstance('e-invoice-eu-cli'); const options = { id: { group: gtx._('Schema selection'), alias: ['i'], type: 'string', choices: ['invoice', 'mapping'], demandOption: true, describe: gtx._('the schema to output'), }, output: { group: gtx._('Output file location'), alias: ['o'], type: 'string', demandOption: false, describe: gtx._('the output file; standard output if `-`'), }, }; class Schema { description() { return gtx._('Output JSON schema.'); } aliases() { return []; } build(argv) { return argv.options(options); } async doRun(configOptions) { const schema = configOptions.id === 'mapping' ? core_1.mappingSchema : core_1.invoiceSchema; const output = JSON.stringify(schema); if (typeof configOptions.output === 'undefined' || configOptions.output === '-') { await (0, safe_stdout_write_1.safeStdoutWrite)(output); } else { await fs.writeFile(configOptions.output, output, 'utf-8'); } } async run(argv) { const configOptions = argv; if (!(0, optspec_1.coerceOptions)(argv, options)) { return 1; } try { await this.doRun(configOptions); return 0; } catch (e) { console.error(gtx._x('{programName}: {error}', { programName: package_1.Package.getName(), error: e, })); return 1; } } } exports.Schema = Schema; //# sourceMappingURL=schema.js.map