-
Notifications
You must be signed in to change notification settings - Fork 3
/
cli.js
executable file
·32 lines (29 loc) · 1.32 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env node
const dotenv = require('dotenv')
const commander = require('commander')
const pgcodebase = require('./index')
dotenv.config()
commander
.option('-u, --user <user>', 'Postgresql user')
.option('-H, --host <host>', 'Postgresql host')
.option('-p, --password <password>', 'Postgresql password')
.option('-d, --database <database>', 'Postgresql database name')
.option('-P, --port <port>', 'Postgresql port')
.option('-C, --connection-string <connectionString>', 'Postgresql connection string')
.option('-s, --schema <schema>', 'Postgresql schema to use')
.option('-D, --dir <dir>', 'Sql files directory')
.option('-c, --create-only', 'Only create entities in database, drop nothing')
.option('-r, --drop-only', 'Only drop entities in database, create nothing')
.parse(process.argv)
pgcodebase({
user: commander.user || process.env.PGUSER,
host: commander.host || process.env.PGHOST,
password: commander.password || process.env.PGPASSWORD,
database: commander.database || process.env.PGDATABASE,
port: commander.port || process.env.PGPORT,
dir: commander.dir || process.env.PGCODEBASE_DIR,
connectionString: commander.connectionString || process.env.PGCODEBASE_CONNECTION_STRING,
createOnly: commander.createOnly,
dropOnly: commander.dropOnly,
schema: commander.schema
}).catch(console.error)