JamesonNetworks/Nirodha

View on GitHub
nirodha

Summary

Maintainability
Test Coverage
#!/usr/bin/env node

/**
 * Module dependencies.
 */

var program = require('commander'),
  logger = require('jslogging'),
  fs = require('fs'),
  path = require('path');

/**
 * Internal wiring
 */

var create = require('./bin/create.js'),
  start = require('./bin/start.js'),
  deploy = require('./bin/deploy.js'),
  watch = require('./bin/watch.js');

/**
 * Try to get settings, otherwise use defaults
 */
 
try {
  var settings = require('./settings.json');
}
catch(err) {
  logger.warn('No settings file found, using default settings...');
  var settings = require('./settings_template.json');
}

program
  .version('1.0.0')
  .option('-c, --create', 'Create a new Nirodha project')
  .option('-s, --start', 'Start hosting the Nirodha project, to enable compression pass withCompression to the -s switch')
  .option('-d, --deploy', 'Transpile the Nirodha project to the deploy folder')
  .option('-w, --watch', 'Watch the directory and perform a deploy when the files change');

program.parse(process.argv);

if(program.create) {
  create(program.args, settings);
}
else if(program.start) {
  start(program.args, settings);
}
else if (program.deploy) {
  deploy(program.args, settings);
}
else if(program.watch) {
  watch(program.args, settings);
}
else {
  logger.warn('No mode specified!');
  console.log("You did not specify a valid operation, perhaps you are missing a switch like '-c'? Consult 'nirodha -h' for more info");
}