-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbin.js
More file actions
executable file
·36 lines (30 loc) · 883 Bytes
/
bin.js
File metadata and controls
executable file
·36 lines (30 loc) · 883 Bytes
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
35
36
#!/usr/bin/env node
'use strict';
var fromMssql = require('./');
var fs = require('fs');
var argv = require('yargs')
.usage('Usage: $0 config_file')
.demand(1)
.alias('q', 'query')
.describe('q', 'sql query')
.alias('b', 'batch')
.describe('b', 'batch size')
.alias('c', 'conn')
.describe('c', 'connection information object')
.help('h')
.alias('h', 'help')
.example(`$0 config.json -q 'select * from table'`, `use config file, overide query in config`)
.epilog('Copyright (c) 2015 Applied Geographics, Inc.\nLicensed under The MIT License')
.argv;
fs.readFile(argv._[0], (err, resp) => {
var config = null;
if (err) {
config = {};
} else {
config = JSON.parse(resp.toString());
}
var c = argv.c || config.conn;
var q = argv.q || config.query;
var b = argv.b || config.batchSize;
fromMssql(c, q, b).pipe(process.stdout);
});