#!/usr/bin/env node

/**
 * Jit hash-object
 */
var program = require('commander'),
    Blob = require('./common/blob');

program
  // TODO
  .option('-t <type>', 'object type')
  // TODO
  .option('-w', 'write the object into the object database')
  // TODO
  .option('--stdin', 'read the object from stdin')
  // TODO
  .option('--stdin-paths', 'read file names from stdin')
  // TODO
  .option('--no-filters store file as is without filters')
  // TODO
  .option('--path <file>', 'process file as it were from this path')
  .parse(process.argv);


content = '';

if(program.stdin) {
  process.stdin.on('data', function(chunk) {
    content += chunk;
  })
  process.stdin.on('end', function() {
    run();
  })
} else {
  run();
}

function run() {
  Blob.hash_object({content: content}, function(err, blob) {
    console.log(blob)
  });
}

@@ -77,16 +77,68 @@
 nder'),%0A
+    fs = require('fs'),%0A    path = require('path'),%0A
     Blob
@@ -290,34 +290,24 @@
  database')%0A
-  // TODO%0A
   .option('-
@@ -750,16 +750,194 @@
 %0A  %7D)%0A%7D 
+else if(program.args.length %3E 0) %7B%0A  var file_path = path.resolve(program.args%5B0%5D);%0A  fs.readFile(file_path, 'utf8', function(err, data) %7B%0A    content = data;%0A    run();%0A  %7D);%0A%7D%0A
 else %7B%0A 
@@ -966,17 +966,42 @@
 n() %7B%0A  
-B
+var blob = new Blob();%0A  b
 lob.hash
@@ -1044,21 +1044,18 @@
 (err
-, blob
 ) %7B%0A   
+ //
  con
@@ -1068,16 +1068,17 @@
 og(blob)
+;
 %0A  %7D);%0A%7D

Allow filling content of a blob from file path