in loader/dbloader.js [40:124]
function parse_command_line() {
var i, len, handler, options;
handler = new CommandLine.FlagHandler();
options = {
"adapter" : "ndb",
"plugin" : new LoaderModule(handler),
"deployment" : "test"
};
handler.addOption(new CommandLine.Option(
"-a", "--adapter=<adapter>",
"Use Jones database driver <adapter> (default: ndb)",
function(nextArg) {
if(typeof nextArg === 'string') {
options.adapter = nextArg;
return 1;
}
return -1; // adapter is required
}));
handler.addOption(new CommandLine.Option(
null, "--stats", "collect statistics", function(nextArg) {
options.stats = true;
return 0;
}));
handler.addOption(new CommandLine.Option(
"-d", "--debug", "enable debugging output", function(nextArg) {
unified_debug.on();
unified_debug.level_debug();
return 0;
}));
handler.addOption(new CommandLine.Option(
null, "-df", "enable debugging output from <source_file>", function(nextArg) {
unified_debug.on();
unified_debug.set_file_level(nextArg, 5);
return 1;
}));
handler.addOption(new CommandLine.Option(
"-c", null, "<ndb_connect_string>", function(nextArg) {
options.connect_string = nextArg;
return 1;
}));
handler.addOption(new CommandLine.Option(
"-f", null, "<control_file>", function(nextArg) {
options.control_file = nextArg;
return 1;
}));
handler.addOption(new CommandLine.Option(
"-e", null, "<load_data_command_text>", function(nextArg) {
options.control_text = nextArg;
return 1;
}));
handler.addOption(new CommandLine.Option(
"-j", null, "<javascript_plugin_file>", function(nextArg) {
/* Here is the code that actually loads the user's module: */
var modulePath;
options.plugin_file = nextArg;
modulePath = options.plugin_file;
// Assume the module path is relative to PWD unless it begins with / or .
if(modulePath[0] !== "." && modulePath[0] !== "/") {
modulePath = "./" + modulePath;
}
require(modulePath).init(options.plugin);
return 1;
}));
handler.addOption(new CommandLine.Option(
"-h", "--help", "show usage", function(nextArg) {
usage(handler);
process.exit(1);
}));
handler.addOption(new CommandLine.Option(
"-E", "--deployment=<name>",
"use deployment <name> from jones_deployments.js",
function(thisArg) {
options.deployment = thisArg;
return 1;
}));
handler.processArguments();
if(! (options.control_file || options.control_text || options.plugin)) {
usage(handler);
}
return options;
}