<commit_before>"use strict";

var fs = require( "fs" );
var resolve = require( "path" ).resolve;

function tempFile( content ) {
	var temp = require( "temp" );
	temp.track();
	var file = temp.openSync( "wires" );
	fs.writeSync( file.fd, content );
	fs.close( file.fd );
	return file.path;
}

function displayHelpAndExit( exitCode ) {
	var path = require( "path" );
	var engineName = process.argv[ 0 ];
	engineName = path.basename( engineName, path.extname( engineName ) );
	console.log( fs.readFileSync( __dirname + "/cli-help.txt" ).toString().replace( /ENGINE/g, engineName ) );
	process.exit( exitCode || 0 );
}

function error( message ) {
	console.error( "ERROR: " + message + "\n" );
	displayHelpAndExit( -1 );
}

function generateRequire( path ) {
	return "require(" + JSON.stringify( path ) + ");\n";
}

function generateArgv( index, value ) {
	return "process.argv[ " + index + " ] = " + JSON.stringify( value ) + ";\n";
}

var evaluators = {
	"-e": true,
	"--eval": true,
	"-i": true,
	"--interactive": true,
	"-p": true,
	"--print": true
};

var wiresOptions = {
	"--help": displayHelpAndExit,
	"--version": function() {
		console.log( "v" + require( "../package" ).version );
		process.exit( 0 );
	},
	"-h": "--help",
	"-v": "--version"
};

var rCommand = /^-/;

// Get the command
var command = process.argv[ 0 ];

// Get this very binary
var self = process.argv[ 2 ];

// Get the command-line arguments
var argv = process.argv.slice( 2 );

// Let's get the target script and args
var targetScript;
var args = [];

var length = argv.length;
var arg;

for ( var i = 0; !targetScript && i < length; i++ ) {
	arg = argv[ i ];
	// If this is a -something argument
	if ( rCommand.test( arg ) ) {
		// Refuse eval-related ones
		if ( evaluators[ arg ] ) {
			error( "-e and -p options are not supported" );
		}
		if ( wiresOptions[ arg ] ) {
			if ( typeof wiresOptions[ arg ] === "string" ) {
				arg = wiresOptions[ arg ];
			}
			wiresOptions[ arg ]();
		}
		// Keep the argument
		args.push( arg );<commit_msg>Specify name and version of the engine when providing wires version<commit_after>"use strict";

var fs = require( "fs" );
var path = require( "path" );
var resolve = require( "path" ).resolve;

// Get the command
var command = process.argv[ 0 ];

// Deduce the engine name
var engineName = path.basename( command, path.extname( command ) );

function tempFile( content ) {
	var temp = require( "temp" );
	temp.track();
	var file = temp.openSync( "wires" );
	fs.writeSync( file.fd, content );
	fs.close( file.fd );
	return file.path;
}

function displayHelpAndExit( exitCode ) {
	console.log( fs.readFileSync( __dirname + "/cli-help.txt" ).toString().replace( /ENGINE/g, engineName ) );
	process.exit( exitCode || 0 );
}

function error( message ) {
	console.error( "ERROR: " + message + "\n" );
	displayHelpAndExit( -1 );
}

function generateRequire( path ) {
	return "require(" + JSON.stringify( path ) + ");\n";
}

function generateArgv( index, value ) {
	return "process.argv[ " + index + " ] = " + JSON.stringify( value ) + ";\n";
}

var evaluators = {
	"-e": true,
	"--eval": true,
	"-i": true,
	"--interactive": true,
	"-p": true,
	"--print": true
};

var wiresOptions = {
	"--help": displayHelpAndExit,
	"--version": function() {
		console.log( "v" + require( "../package" ).version + " (" + engineName + " " + process.version + ")" );
		process.exit( 0 );
	},
	"-h": "--help",
	"-v": "--version"
};

// Get the command-line arguments
var argv = process.argv.slice( 2 );

// Let's get the target script and args
var targetScript;
var args = [];

var rCommand = /^-/;

var length = argv.length;
var arg;

for ( var i = 0; !targetScript && i < length; i++ ) {
	arg = argv[ i ];
	// If this is a -something argument
	if ( rCommand.test( arg ) ) {
		// Refuse eval-related ones
		if ( evaluators[ arg ] ) {
			error( "-e and -p options are not supported" );
		}
		if ( wiresOptions[ arg ] ) {
			if ( typeof wiresOptions[ arg ] === "string" ) {
				arg = wiresOptions[ arg ];
			}
			wiresOptions[ arg ]();
		}
		// Keep the argument
		args.push( arg );
{'fraction_non_alphanumeric': 0.18444935001226392, 'fraction_numerical': 0.003433897473632573, 'mean_word_length': 3.186858316221766, 'pattern_counts': {'":': 20, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4345758', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1399, 'n_words': 419}