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.

109 lines 4.26 kB
#! /usr/bin/env node "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; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const runtime_1 = require("@esgettext/runtime"); const path = __importStar(require("path")); const v = __importStar(require("valibot")); require("@valibot/i18n/de"); const yargs_1 = __importDefault(require("yargs")); const format_1 = require("./commands/format"); const invoice_1 = require("./commands/invoice"); const schema_1 = require("./commands/schema"); const transform_1 = require("./commands/transform"); const validate_1 = require("./commands/validate"); const package_1 = require("./package"); const commandNames = ['invoice', 'transform', 'validate', 'format', 'schema']; const gtx = runtime_1.Textdomain.getInstance('e-einvoice-eu-cli'); v.setGlobalConfig({ lang: runtime_1.Textdomain.locale }); const localePath = path.join(__dirname, 'locale'); gtx.bindtextdomain(localePath); gtx .resolve() .then(async () => { let exitCode = 0; const ulocale = runtime_1.Textdomain.locale.replace('-', '_'); const commands = { invoice: new invoice_1.Invoice(), transform: new transform_1.Transform(), validate: new validate_1.Validate(), format: new format_1.Format(), schema: new schema_1.Schema(), }; const program = (0, yargs_1.default)(process.argv.slice(2)) .locale(ulocale) .strict() .showHelpOnFail(false, gtx._x("Try '{programName} --help' or '{programName} COMMAND --help' for more information!", { programName: package_1.Package.getName(), })) .alias('V', 'version') .alias('h', 'help') .demandCommand(1, gtx._('Error: No command given.')) .scriptName(package_1.Package.getName()); for (const name of commandNames) { const command = commands[name]; const commandName = command.synopsis ? `${name} ${command.synopsis()}` : name; program.command({ command: commandName, aliases: command.aliases(), describe: command.description(), builder: (argv) => { return command.build(argv); }, handler: async (argv) => { argv._.shift(); exitCode = await command.run(argv); }, }); } const epilogue = gtx._x('Report bugs in the bugtracker at\n{url}!', { url: package_1.Package.getBugTrackerUrl(), }); await program.help().epilogue(epilogue).parse(); process.exit(exitCode); }) .catch((exception) => { console.error(gtx._x('{programName}: unhandled exception: {exception}'), { programName: package_1.Package.getName(), exception, }); process.exit(2); }); //# sourceMappingURL=index.js.map