#!/usr/bin/env node

var generateShader = function generateShader (args) {
    var ruleString = args[0] || null,
        outOfBoundValue = args[1] || 'wrap';

    outOfBoundValue = outOfBoundValue == 'wrap' || outOfBoundValue == 'clamp' ? outOfBoundValue : parseInt(outOfBoundValue, 10);

    console.log(generator(ruleString, outOfBoundValue));
};

var extractInformation = function extractInformation (content) {
    // not critical, dumb regular expressions will do
    var regexVersion = new RegExp('^/\\*\\*[\\S\\s]+cellular-automata-voxel-shader ([0-9.]+)[\\S\\s]+\\*/', 'mg'),
        regexRuleString = new RegExp('^/\\*\\*[\\S\\s]+Rule : (.+)[\\S\\s]+\\*/', 'mg'),
        regexOutOfBound = new RegExp('^/\\*\\*[\\S\\s]+Out of bound value : (.+)[\\S\\s]+\\*/', 'mg'),
        versionMatch = regexVersion.exec(content),
        ruleStringMatch = regexRuleString.exec(content),
        outOfBoundMatch = regexOutOfBound.exec(content);

    return {
        version : versionMatch ? versionMatch[1] : null,
        ruleString : ruleStringMatch ? ruleStringMatch[1] : null,
        outOfBoundValue : outOfBoundMatch ? outOfBoundMatch[1] : null,
        valid : versionMatch && ruleStringMatch && outOfBoundMatch
    };
};

var getInformation = function getInformation (args) {
    var fs = require('fs'),
        filename = args[1] || null,
        content,
        information;

    if (filename) {
        try {
            content = fs.readFileSync(filename).toString();
        } catch (e) {
            content = null;
        }

        information = extractInformation(content);

        if (information.valid) {
            console.log(filename + ' : ' + information.ruleString + ' : ' + information.outOfBoundValue + ' : generated by cavoxelshader ' + information.version);
        } else {
            console.log(filename + ' was not generated by cavoxelshader');
        }
    }
};

var generator = require('./../'),
    args = process.argv.slice(2);

if (args[0] === 'info') {
    getInformation(args);
} else {
    generateShader(args);
}

@@ -14,16 +14,41 @@
 v node%0A%0A
+var fs = require('fs');%0A%0A
 var gene
@@ -1249,19 +1249,23 @@
 %7D;%0A%0Avar 
-get
+display
 Informat
@@ -1279,19 +1279,23 @@
 unction 
-get
+display
 Informat
@@ -1303,87 +1303,27 @@
 on (
-args) %7B%0A    var fs = require('fs'),%0A        filename = args%5B1%5D %7C%7C null,
+filename) %7B
 %0A    
-   
+var
  con
@@ -1354,32 +1354,8 @@
 n;%0A%0A
-    if (filename) %7B%0A    
     
@@ -1360,20 +1360,16 @@
   try %7B%0A
-    
         
@@ -1416,20 +1416,16 @@
 ring();%0A
-    
     %7D ca
@@ -1430,28 +1430,24 @@
 catch (e) %7B%0A
-    
         cont
@@ -1466,19 +1466,11 @@
     
-    %7D%0A%0A    
+%7D%0A%0A
     
@@ -1513,20 +1513,16 @@
 tent);%0A%0A
-    
     if (
@@ -1538,28 +1538,24 @@
 on.valid) %7B%0A
-    
         cons
@@ -1701,20 +1701,16 @@
 rsion);%0A
-    
     %7D el
@@ -1714,20 +1714,16 @@
  else %7B%0A
-    
         
@@ -1751,11 +1751,9 @@
 + ' 
-was
+:
  not
@@ -1787,21 +1787,369 @@
 ');%0A    
-    %7D
+%7D%0A%7D;%0A%0Avar infoCommand = function infoCommand (args) %7B%0A    var filename = args%5B1%5D %7C%7C null;%0A%0A    if (filename) %7B%0A        displayInformation(filename);%0A    %7D else %7B%0A        fs.readdirSync('./').map(function(file) %7B%0A            if (file.indexOf('.') !== 0 && fs.lstatSync(file).isFile()) %7B%0A                displayInformation(file);%0A            %7D%0A        %7D);
 %0A    %7D%0A%7D
@@ -2254,22 +2254,19 @@
     
-getInformation
+infoCommand
 (arg

Change info command to list all the files in the current folder when used without filename