Skip to content

Commit

Permalink
Merge branch 'master' of github.com:baudehlo/Haraka
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Sergeant committed May 19, 2011
2 parents 566c6de + 9a7432f commit b52667f
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions bin/haraka
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ var fs = require('fs'),
"version": Boolean,
"help": [String, null],
"configs": path,
"install": path
"install": path,
"list": Boolean
},
shortHands = {
"v": ["--version"],
"h": ["--help"],
"c": ["--configs"],
"i": ["--install"]
"i": ["--install"],
"l": ["--list"]
},
parsed = nopt(knownOpts, shortHands, process.argv, 2);

Expand All @@ -34,10 +36,37 @@ var usage = [
"\t-h, --help \t\tOutputs this help message",
"\t-h NAME \t\tShows help for NAME",
"\t-c, --configs \t\tPath to your config directory",
"\t-i, --install \t\tCopies the default configs to a specified dir"
"\t-i, --install \t\tCopies the default configs to a specified dir",
"\t-l, --list \t\tList the plugins bundled with Haraka"
].join('\n');


var listPlugins = function (b, dir) {

if (!dir) { dir = "plugins/"; }

var plist = dir + "\n",
subdirs = [],
gl = path.join((b ? b : base), dir),
pd = fs.readdirSync(gl);

pd.forEach(function (p) {
if (~p.search('.js')) {
plist += "\t" + p.replace('.js', '') + "\n";
} else {
subdirs.push(dir + p + "/");
}
});

subdirs.forEach(function (s) {
plist += "\n" + listPlugins(b, s);
});

return plist;

}


// Show message when create
function create(path) {
// console.log('\x1b[32mcreate\x1b[0m: ' + path);
Expand Down Expand Up @@ -167,6 +196,12 @@ function createReadme(readmePath) {
if (parsed.version) {
console.log("\033[32;40mHaraka.js\033[0m — Version: " + ver);
}
else if (parsed.list) {
console.log("\033[32;40m*global\033[0m\n" + listPlugins());
if (parsed['configs']) {
console.log("\033[32;40m*local\033[0m\n" + listPlugins(parsed['configs']));
}
}
else if (parsed.help) {
if (parsed.help === 'true') {
console.log(usage);
Expand All @@ -188,6 +223,7 @@ else if (parsed.help) {
else if (parsed['configs']) {

process.env.HARAKA = parsed['configs'];
require.paths.unshift(path.join(process.env.HARAKA, 'node_modules'));

var logger = require(path.join(base, 'logger'))
server = require(path.join(base, 'server'));
Expand Down

0 comments on commit b52667f

Please sign in to comment.