// CLI tools
var bluebird  = require('bluebird');
var debug     = require('debug')('index');
var size      = 20;

// requires parameters
var page      = process.env.batch || 1;
var startDate = process.env.start;
var dataDir   = process.env.dataDir;
debug(page, startDate, dataDir);
var gigatool  = require('./lib/gigatool')(size, page, dataDir);

bluebird.all([gigatool.clean(startDate), gigatool.continuous()])
  .finally(function(){
    process.exit(0);
  });
@@ -1,16 +1,24 @@
-// CLI tools
+#!/usr/bin/env node%0A
 %0Avar
@@ -47,24 +47,67 @@
 bluebird');%0A
+var gigatool  = require('./lib/gigatool');%0A
 var debug   
@@ -162,31 +162,8 @@
 0;%0A%0A
-// requires parameters%0A
 var 
@@ -190,18 +190,13 @@
 env.
-batch %7C%7C 1
+BATCH
 ;%0Ava
@@ -221,21 +221,21 @@
 ess.env.
-start
+START
 ;%0Avar da
@@ -256,23 +256,23 @@
 ess.env.
-dataDir
+DATADIR
 ;%0Adebug(
@@ -302,47 +302,135 @@
 r);%0A
-var gigatool  = require('./lib/
+%0A// requires parameters%0Aif (!process.env.BATCH) %7B%0A  throw new Error('BATCH environment variable is needed');%0A%7D%0A%0Atool = 
 gigatool
 ')(s
@@ -425,18 +425,16 @@
 gigatool
-')
 (size, p
@@ -449,16 +449,33 @@
 aDir);%0A%0A
+module.exports = 
 bluebird
@@ -480,20 +480,16 @@
 rd.all(%5B
-giga
 tool.cle
@@ -503,20 +503,16 @@
 tDate), 
-giga
 tool.con
@@ -546,16 +546,47 @@
 tion()%7B%0A
+    if (!process.env.TEST) %7B%0A  
     proc
@@ -598,13 +598,19 @@
 xit(0);%0A
+    %7D%0A
   %7D);

change env vars to uppercase and expose runners