UNPKG

@electric-sql/cli

Version:

ElectricSQL command line interface (CLI).

36 lines 977 B
import { Command } from "commander"; import { addOptionGroupToCommand, getConfig } from '../config.js'; import { buildDatabaseURL, parsePgProxyPort } from '../util/index.js'; import { dockerCompose } from './docker-utils.js'; function makePsqlCommand() { const command = new Command("psql"); command.description("Connect with psql to the ElectricSQL PostgreSQL proxy"); addOptionGroupToCommand(command, "proxy"); command.action(async (opts) => { psql(opts); }); return command; } function psql(opts) { const config = getConfig(opts); const containerDbUrl = buildDatabaseURL({ user: config.DATABASE_USER, password: config.PG_PROXY_PASSWORD, host: "electric", port: parsePgProxyPort(config.PG_PROXY_PORT).port, dbName: config.DATABASE_NAME }); dockerCompose( "exec", ["-it", "postgres", "psql", containerDbUrl], config.CONTAINER_NAME ); } export { makePsqlCommand, psql }; //# sourceMappingURL=command-psql.js.map