amass
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -17,5 +17,5 @@ #!/usr/bin/env node | ||
var getopt = require('posix-getopt'); | ||
var plugins = require('../plugins'); | ||
var package = require('../package.json'); | ||
var pluginsdir = '/var/amass/node_modules'; | ||
@@ -33,5 +33,11 @@ /** | ||
'', | ||
'-h, --help print this message and exit', | ||
'-u, --updates check for available updates', | ||
'-v, --version print the version number and exit' | ||
'plugins are installed to `' + plugins.dir + '\' and as such, may', | ||
'require root or super-user privileges', | ||
'', | ||
'-a, --add <name> add the plugin <name> to amass', | ||
'-h, --help print this message and exit', | ||
'-l, --list list the currently installed plugins', | ||
'-l, --remove <name> remove the plugin <name> from amass', | ||
'-u, --updates check for available updates', | ||
'-v, --version print the version number and exit' | ||
].join('\n'); | ||
@@ -42,3 +48,6 @@ } | ||
var options = [ | ||
'a(add)', | ||
'h(help)', | ||
'l(list)', | ||
'r(remove)', | ||
'u(updates)', | ||
@@ -48,6 +57,12 @@ 'v(version)' | ||
var parser = new getopt.BasicParser(options, process.argv); | ||
var add = false; | ||
var list = false; | ||
var remove = false; | ||
var option; | ||
while ((option = parser.getopt()) !== undefined) { | ||
switch (option.option) { | ||
case 'a': add = true; break; | ||
case 'h': console.log(usage()); process.exit(0); | ||
case 'l': list = true; break; | ||
case 'r': remove = true; break; | ||
case 'u': // check for updates | ||
@@ -63,9 +78,21 @@ require('latest').checkupdate(package, function(ret, msg) { | ||
} | ||
var args = process.argv.slice(parser.optind()); | ||
// try to load the plugin | ||
var plugins; | ||
// handle add, remove, or list | ||
function cb(err, out, code) { | ||
if (out) process.stdout.write(out); | ||
if (err) process.stderr.write(err); | ||
process.exit(code); | ||
} | ||
if (add) return plugins.add(args, cb); | ||
if (list) return plugins.list(cb); | ||
if (remove) return plugins.remove(args, cb); | ||
// try to load the plugins | ||
var pluginsavail; | ||
try { | ||
var pluginnames = fs.readdirSync(pluginsdir); | ||
plugins = pluginnames.map(function(name) { | ||
return path.join(pluginsdir, name); | ||
var pluginnames = fs.readdirSync(plugins.dir); | ||
pluginsavail = pluginnames.map(function(name) { | ||
// return the full path | ||
return path.join(plugins.dir, name); | ||
}); | ||
@@ -75,3 +102,3 @@ } catch (e) {} | ||
// amass! | ||
amass(plugins, function(errors, data) { | ||
amass(pluginsavail, function(errors, data) { | ||
if (errors) errors.forEach(function(err) { | ||
@@ -78,0 +105,0 @@ console.error(err); |
@@ -31,3 +31,3 @@ /** | ||
version: package.version, | ||
plugins: plugins | ||
plugins: plugins || [] | ||
}; | ||
@@ -34,0 +34,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "Dave Eddy <dave@daveeddy.com> (http://www.daveeddy.com)", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"bin": { | ||
@@ -24,4 +24,5 @@ "amass": "./bin/amass.js" | ||
"latest": "~0.1.0", | ||
"posix-getopt": "~1.0.0" | ||
"posix-getopt": "~1.0.0", | ||
"exec": "0.0.4" | ||
} | ||
} |
7440
8
205
3
4
+ Addedexec@0.0.4
+ Addedexec@0.0.4(transitive)