forked from pouchdb/add-cors-to-couchdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.js
34 lines (33 loc) · 854 Bytes
/
bin.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
33
34
#!/usr/bin/env node
'use strict';
var cbc = require('./');
var yargs = require('yargs')
.alias('p', 'password')
.describe('p', 'your password')
.alias('u', 'username')
.describe('u', 'your username')
.alias('h', 'help')
.describe('h', 'this help')
.version(require('./package.json').version, 'v')
.alias('v', 'version')
.usage('\nUsage:\n $0 [url] [options]')
.example('$0', 'update couch at http://127.0.0.1:5984')
.example('$0 http://me.iriscouch.com -u me -p pw', 'update with auth');
var argv = yargs.argv;
if (argv.h) {
yargs.showHelp();
return process.exit(0);
}
var auth;
if (argv.p && argv.u) {
auth = argv.u + ':' + argv.p;
}
var url = argv._[0] || 'http://127.0.0.1:5984';
cbc(url, auth, function (err) {
if (err) {
console.log(err);
process.exit(1);
}
console.log('success');
process.exit(0);
});