28 lines
494 B
JavaScript
Executable File
28 lines
494 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
(function () {
|
|
'use strict';
|
|
|
|
var hexdump = require('../').hexdump;
|
|
var fsname = process.argv[2];
|
|
var fs = require('fs');
|
|
|
|
if (!fsname || '--help' === fs || '-h' === fs) {
|
|
console.error('Usage: hexdump.js <filepath>');
|
|
process.exit(2);
|
|
return;
|
|
}
|
|
|
|
try {
|
|
fs.statSync(fsname);
|
|
} catch(e) {
|
|
console.error(e.message);
|
|
process.exit(3);
|
|
return;
|
|
}
|
|
|
|
var nb = fs.readFileSync(fsname);
|
|
var str = hexdump(nb.buffer, nb.byteOffset, nb.byteLength);
|
|
console.log(str);
|
|
|
|
}());
|