@mesh-tech/mesh-cli
Version:
CLI for Mesh platform development utilities
53 lines (52 loc) • 3.08 kB
JavaScript
import { connectCommand } from "./connect.js";
import { credentialsCommand } from "./credentials.js";
import { envCommand } from "./env.js";
import { psqlCommand } from "./psql.js";
import { execCommand } from "./exec.js";
export function registerDbCommands(program) {
const db = program
.command("db")
.description("Database utilities");
db.command("connect")
.description("Start DB tunnel for manual psql access")
.option("-t, --tenant <tenant>", "Platform tenant (e.g., mesh)")
.option("-e, --env <env>", "Platform environment (e.g., dev-temporal)")
.action(connectCommand);
db.command("credentials")
.alias("creds")
.description("Print database credentials")
.option("-t, --tenant <tenant>", "Platform tenant (e.g., mesh)")
.option("-e, --env <env>", "Platform environment (e.g., dev-temporal)")
.option("-a, --app <app>", "App name for credentials path (e.g., rdc)")
.option("--app-tenant <tenant>", "Tenant for app credentials (e.g., encore)")
.option("--app-stage <stage>", "Stage for app credentials (e.g., dev)")
.action(credentialsCommand);
db.command("env")
.description("Export DATABASE_URL for current shell (use with eval)")
.option("-t, --tenant <tenant>", "Platform tenant (e.g., mesh)")
.option("-e, --env <env>", "Platform environment (e.g., dev-temporal)")
.option("-a, --app <app>", "App name for credentials path (e.g., rdc)")
.option("--app-tenant <tenant>", "Tenant for app credentials (e.g., encore)")
.option("--app-stage <stage>", "Stage for app credentials (e.g., dev)")
.action(envCommand);
db.command("psql")
.description("Connect to database with psql")
.option("-t, --tenant <tenant>", "Platform tenant (e.g., mesh)")
.option("-e, --env <env>", "Platform environment (e.g., dev-temporal)")
.option("-a, --app <app>", "App name for credentials path (e.g., rdc)")
.option("--app-tenant <tenant>", "Tenant for app credentials (e.g., encore)")
.option("--app-stage <stage>", "Stage for app credentials (e.g., dev)")
.action(psqlCommand);
db.command("exec")
.description("Run any command with database connection")
.option("-t, --tenant <tenant>", "Platform tenant for bastion lookup (e.g., mesh)")
.option("-e, --env <env>", "Platform environment for bastion lookup (e.g., dev-temporal)")
.option("-a, --app <app>", "App name for credentials path (e.g., rdc)")
.option("--app-tenant <tenant>", "Tenant for app credentials if different from platform (e.g., encore)")
.option("--app-stage <stage>", "Stage for app credentials (e.g., dev)")
.option("--secret <arn>", "Use secret ARN directly (skips SSM discovery)")
.option("--ssl <mode>", "SSL mode: require, no-verify, disable")
.option("--port <port>", "Local tunnel port (default: 5432)")
.argument("<command...>", "Command and arguments to run")
.action(execCommand);
}