#!/usr/bin/env node
"use strict"

var cli = require("cli"),
    glob = require("glob"),
    json = require("jsonfile"),
    filePath = "/app/walmart-frontend/webstore/assets/desktop/template/**/wm-component.json",
    appSettings = require("./lib/AppSettings"),
    outputFile = "/app/walmart-frontend/webstore/settings.json",
    output = [];

function readJson(filePath) {
  glob(filePath, function(err, files) {
    for(var i = 0; i < files.length; i++) {
      cli.info("Found component: " + files[i]);
      var obj = json.readFileSync(files[i]),
          newObject = appSettings()
                      .createPage(obj)
                      .addScript(obj)
                      .getObject();

      output.push(newObject);
    }
  });
}

function writeJson(filePath, obj) {
  json.writeFileSync(filePath, obj, {spaces: 2}, function (err) {
    cli.info(err);
  })
  cli.info("creating " + filePath);
}

readJson(filePath);
writeJson(outputFile, output);

@@ -109,24 +109,60 @@
 jsonfile%22),%0A
+    program = require(%22commander%22),%0A
     filePath
@@ -374,16 +374,371 @@
  = %5B%5D;%0A%0A
+%0A    program%0A      .version('0.1.0')%0A      .option('-i, --init', 'make initial component structure')      %0A%0A    program.on('--help', function()%7B%0A      console.log('  Examples:');%0A      console.log('');%0A      console.log('    $ node app --help');%0A      console.log('    $ node app -h');%0A      console.log('');%0A    %7D);%0A%0A    program.parse(process.argv);%0A%0A%0A%0A%0A
 function

Implement commander