UNPKG

@pgsql/cli

Version:

Unified CLI for PostgreSQL AST parsing, deparsing, and code generation

42 lines (38 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.help = void 0; const helpers_1 = require("./helpers"); const help = () => { console.log(` Usage: pg-proto-parser protogen --protoUrl <URL to proto file> --inFile <path to proto file> --outFile <path to output JS file> --originalPackageName <original package name> --newPackageName <new package name> Options: --help, -h Show this help message. --version, -v Show the version number. --protoUrl Full URL to download the proto file (optional). --inFile Path where the proto file will be saved or path to an existing proto file. --outFile Path where the generated JavaScript file will be saved. --originalPackageName Original package name to be replaced in the JS file. --newPackageName New package name to replace in the JS file. `); }; exports.help = help; exports.default = async (argv) => { try { if (argv.protoUrl) { await (0, helpers_1.downloadProtoFile)(argv.protoUrl, argv.inFile); } await (0, helpers_1.generateProtoJS)(argv.inFile, argv.outFile); await (0, helpers_1.replaceTextInProtoJS)(argv.outFile, argv.originalPackageName, argv.newPackageName); console.log('All operations completed successfully.'); } catch (error) { // @ts-ignore console.error('An error occurred:', error.message); } return argv; };