-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
44 lines (32 loc) · 1.4 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
33
34
35
36
37
38
39
40
41
42
43
44
//TODO - fix error handling
var dnsDB = require('./dnsDB.js');
var query = process.argv[2];
var dnsRecord = process.argv[3];
var writeMode = process.argv[4];
var dnsServer = process.argv[5];
var verbose = process.argv[6];
// --
// --
// -- node cli.js "SELECT * FROM content" storage2.db.dellol.io false 8.8.8.8 true
// -- node cli.js "SELECT * FROM content WHERE field_id = '91'" storage5.db.dellol.io false 8.8.8.8 false
// -- node cli.js "INSERT INTO content (field_id, name, value) VALUES (91, 'ryan', '<h>react?</h>')" storage5.db.dellol.io true 8.8.8.8 true
// --
var output = dnsDB(dnsRecord, "key", writeMode, dnsServer, verbose, function ( db, debug, ){ //creates a sqlite3 db from a DNS call. true denotes write mode
db.serialize(function() { //use as you normally would per https://www.npmjs.com/package/sqlite3
db.each(query, function(err, row) {
//display
if(row){
console.log('\x1b[34m%s\x1b[0m', row.field_id + " | " + row.name + " | " + row.value);
} else if( row == undefined ){
console.log('\x1b[31m%s\x1b[0m', "Empty response");
} else {
console.log('\x1b[31m%s\x1b[0m', err);
}
});
db.exec("", function ( ){
if(verbose == 'true'){
console.log(debug);
}
});
});
});