diff --git a/bin/cylon b/bin/cylon new file mode 100755 index 0000000..1640c95 --- /dev/null +++ b/bin/cylon @@ -0,0 +1,13 @@ +#!/usr/bin/env node + +var program = require('commander'), + cylon = require('../package.json'); + +program.version(cylon.version); + +program + .command("generate ") + .description("Generates a new adaptor") + .action(function(name) { require('../src/generators/adaptor')(name) }); + +program.parse(process.argv); diff --git a/package.json b/package.json index 06cca11..d9d0671 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,9 @@ "sinon-chai": "~2.4.0", "chai": "~1.7.2", "mocha": "~1.12.1", - "sinon": "~1.7.3" + "sinon": "~1.7.3", + "wrench": "~1.5.4", + "commander": "~2.1.0" }, "dependencies": { "async": "~0.2.9", diff --git a/src/generators/adaptor.js b/src/generators/adaptor.js new file mode 100644 index 0000000..6d58ab6 --- /dev/null +++ b/src/generators/adaptor.js @@ -0,0 +1,26 @@ +var wrench = require('wrench'); + +var adaptorName = ""; + +// Returns a cylon-namespaced adaptor name +var cylonAdaptorName = function() { + return "cylon-" + adaptorName; +}; + +// Converts the adaptor name to from camel_case to snake_case +var adaptorClassName = function() { + return String(adaptorName) + .replace(/[\W_]/g, ' ') + .toLowerCase() + .replace(/(?:^|\s|-)\S/g, function(c){ return c.toUpperCase(); }) + .replace(/\s/g, ''); +}; + +var generator = function(name) { + adaptorName = name; + console.log("Creating " + cylonAdaptorName() + " adaptor..."); + wrench.copyDirSyncRecursive(__dirname + "/adaptor", cylonAdaptorName()); + console.log("Done!"); +}; + +module.exports = generator; diff --git a/src/generators/adaptor/package.json b/src/generators/adaptor/package.json new file mode 100644 index 0000000..e69de29