Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Cmds.commands(function(err, commands) {
if (err) return done(err);
var packageId = commands[cmd.toLowerCase()], exports;
if (packageId) {
try {
exports = require(packageId);
} catch(e) {
exports = null;
}
}
var opts = new optparse.OptionParser(STD_SWITCHES);
if (!exports || !exports.invoke) {
return Cmds.unknown(cmd, args, opts, done);
} else {
// ok try to parse the options and see if we need to do help
var showHelp = false;
opts.on('help', function() { showHelp = true; });
opts.on('verbose', function() { require.env.VERBOSE = true; });
opts.parse(args);
if (showHelp) {
return help.invoke(cmd, [cmd], opts, done);
} else {
opts = (exports.options || []).slice();
opts = opts.concat(STD_SWITCHES);
opts = new optparse.OptionParser(opts);
return exports.invoke(cmd, args, opts, done);
var opts = new optparse.OptionParser(STD_SWITCHES);
if (!exports || !exports.invoke) {
return Cmds.unknown(cmd, args, opts, done);
} else {
// ok try to parse the options and see if we need to do help
var showHelp = false;
opts.on('help', function() { showHelp = true; });
opts.on('verbose', function() { require.env.VERBOSE = true; });
opts.parse(args);
if (showHelp) {
return help.invoke(cmd, [cmd], opts, done);
} else {
opts = (exports.options || []).slice();
opts = opts.concat(STD_SWITCHES);
opts = new optparse.OptionParser(opts);
return exports.invoke(cmd, args, opts, done);
}
}
});
};
var packageId = commands[cmd], exports;
try {
exports = require(packageId);
} catch(e) {
exports = null;
}
if (!exports || !exports.invoke) {
CORE.println("Unknown command " + cmd);
return done();
}
var opts = (exports.options || []).slice();
opts = opts.concat(Cmds.STD_SWITCHES);
opts = new optparse.OptionParser(opts);
opts.banner = 'usage: seed ' + (exports.usage || cmd);
CORE.println(opts.toString());
if (exports.desc) CORE.println('\n' + exports.desc + '\n');
return done();
});
}