examples/node/config.js
function parseCommandLine() {
	var commands = process.argv.slice(2);
	var args = {};

	for (var i = 0; i < commands.length; i++) {
		var match = commands[i].match(/^--(.+)=(.+)$/);
		if (match)
			args[match[1]] = match[2];
		else if (i < commands.length - 1 && commands[i].substr(0, 1) === "-") {
			args[commands[i].substr(1)] = commands[i + 1];
			i++;
		}
		else if (i === 0) args[commandKey] = commands[i];
		else if (i === 1) args[commandHost] = commands[i];
	}

	return args;
}
function parseCommandLine() {
	var commands = process.argv.slice(2);
	var args = {};

	for (var i = 0; i < commands.length; i++) {
		var match = commands[i].match(/^--(.+)=(.+)$/);
		if (match)
			args[match[1]] = match[2];
		else if (i < commands.length - 1 && commands[i].substr(0, 1) === "-") {
			args[commands[i].substr(1)] = commands[i + 1];
			i++;
		}
		else if (i === 0) args[commandKey] = commands[i];
		else if (i === 1) args[commandHost] = commands[i];
	}

	return args;
}
function parseCommandLine ( ) { var commands = process . argv . slice ( 2 ) ; var args = { } ; for ( var i = 0 ; i < commands . length ; i ++ ) { var match = commands [ i ] . match ( / ^--(.+)=(.+)$ / ) ; if ( match ) args [ match [ 1 ] ] = match [ 2 ] ; else if ( i < commands . length - 1 && commands [ i ] . substr ( 0 , 1 ) === "-" ) { args [ commands [ i ] . substr ( 1 ) ] = commands [ i + 1 ] ; i ++ ; } else if ( i === 0 ) args [ commandKey ] = commands [ i ] ; else if ( i === 1 ) args [ commandHost ] = commands [ i ] ; } return args ; }
Parse command line arguments
Parse command line arguments