example of cli usage

This commit is contained in:
AJ ONeal 2017-01-21 03:18:10 -07:00
parent 23beebf751
commit 6b45a4711f
2 changed files with 23 additions and 18 deletions

23
pure-parser-cli.js Normal file
View File

@ -0,0 +1,23 @@
'use strict';
// EXAMPLE:
// node pure-parser.js samples/a-0.mdns.bin
// pass a terminal arg
var filename = process.argv[2];
if (!filename) {
console.error("Usage: node aj-listener.js <type> [count]");
console.error("Example: node aj-listener.js _service 0");
process.exit(1);
}
var PromiseA = require('bluebird');
var fs = PromiseA.promisifyAll(require('fs'));
var pdns = require('./pure-parser');
fs.readFileAsync(filename, null).then(function (nb) {
// nb is a Uint8Array (ArrayBufferView) for nb.buffer
// nb.buffer is the actual ArrayBuffer
pdns.unpack(nb.buffer);
});

View File

@ -1,23 +1,5 @@
'use strict';
// pass a terminal arg
var filename = process.argv[2];
if (!filename) {
console.error("Usage: node aj-listener.js <type> [count]");
console.error("Example: node aj-listener.js _service 0");
process.exit(1);
}
var PromiseA = require('bluebird');
var fs = PromiseA.promisifyAll(require('fs'));
fs.readFileAsync(filename, null).then(function (nb) {
// nb is a Uint8Array (ArrayBufferView) for nb.buffer
// nb.buffer is the actual ArrayBuffer
pdns.unpack(nb.buffer);
});
var pdns = module.exports;
// Order http://www.zytrax.com/books/dns/ch15/