node-postgres/test/cli.js

55 lines
997 B
JavaScript
Raw Normal View History

2010-10-25 14:30:14 +08:00
var config = {
port: 5432,
host: 'localhost',
user: 'postgres',
database: 'postgres',
password: '',
test: 'unit'
2010-10-25 14:30:14 +08:00
};
var args = process.argv;
for(var i = 0; i < args.length; i++) {
switch(args[i].toLowerCase()) {
case '-u':
case '--user':
config.user = args[++i];
break;
case '--password':
config.password = args[++i];
break;
case '--verbose':
config.verbose = (args[++i] == "true");
break;
2010-10-25 14:30:14 +08:00
case '-d':
case '--database':
config.database = args[++i];
break;
case '-p':
case '--port':
config.port = args[++i];
break;
case '-h':
case '--host':
config.host = args[++i];
break;
case '--down':
config.down = true;
break;
case '-t':
case '--test':
config.test = args[++i];
case '--libpq':
config.libpq = (args[++i] == "true");
2010-10-25 14:30:14 +08:00
default:
break;
}
}
var log = function(keys) {
keys.forEach(function(key) {
console.log(key + ": '" + config[key] + "'");
});
}
2010-10-25 14:30:14 +08:00
module.exports = config;