<commit_before>package sbt

import scala.tools.nsc.{interpreter, util, GenericRunnerCommand, InterpreterLoop, ObjectRunner}
import util.ClassPath
import java.net.URL

object Run
{
	def console(classpath: Iterable[Path], log: Logger) =
	{
		val command = new GenericRunnerCommand(Nil, message => log.error(message))
		if(command.ok)
		{
			val settings = command.settings
			settings.classpath.value = Path.makeString(classpath)
			log.info("Starting scala interpreter...")
			log.debug("  Classpath: " + settings.classpath.value)
			log.info("")
			try
			{
				val loop = new InterpreterLoop
				loop.main(settings)
				// if JLine is used on a unix platform, we need to call restoreTerminal on
				// the underlying UnixTerminal, otherwise inputted characters won't be echoed.
				loop.in match
				{
					case reader: interpreter.JLineReader => restoreTerminal(reader)
					case _ => ()
				}
				None
			}
			catch
			{
				case e: Exception => log.trace(e); Some("Error during run: " + e.getMessage)
			}
		}
		else
			Some(command.usageMsg)
	}
	def run(mainClass: String, classpath: Iterable[Path], options: Seq[String], log: Logger) =
	{
		try
		{
			ObjectRunner.run(classpath.map(_.asFile.toURI.toURL).toList, mainClass, options.toList)
			None
		}
		catch
		{
			case e: Exception => log.trace(e); Some("Error during run: " + e.getMessage)
		}
	}
	def apply(mainClassOption: Option[String], classpath: Iterable[Path], options: Seq[String], log: Logger) =
	{
		mainClassOption match
		{
			case Some(mainClass) => run(mainClass, classpath, options, log)
			case None => console(classpath, log)
		}
	}
	private def restoreTerminal(reader: interpreter.JLineReader)
	{
		val terminal = reader.consoleReader.getTerminal
		try
		{
			type UnixTerminal = { def restoreTerminal: Unit }<commit_msg>Fixed run action to include scala on classpath.<commit_after>package sbt

import scala.tools.nsc.{interpreter, util, GenericRunnerCommand, InterpreterLoop, ObjectRunner, Settings}
import util.ClassPath
import java.net.URL

object Run
{
	def console(classpath: Iterable[Path], log: Logger) =
		createSettings(log)
		{
			(settings: Settings) =>
			{
				settings.classpath.value = Path.makeString(classpath)
				log.info("Starting scala interpreter...")
				log.debug("  Classpath: " + settings.classpath.value)
				log.info("")
				try
				{
					val loop = new InterpreterLoop
					loop.main(settings)
					// if JLine is used on a unix platform, we need to call restoreTerminal on
					// the underlying UnixTerminal, otherwise inputted characters won't be echoed.
					loop.in match
					{
						case reader: interpreter.JLineReader => restoreTerminal(reader)
						case _ => ()
					}
					None
				}
				catch
				{
					case e: Exception => log.trace(e); Some("Error during session: " + e.getMessage)
				}
			}
		}
	def run(mainClass: String, classpath: Iterable[Path], options: Seq[String], log: Logger) =
	{
		createSettings(log)
		{
			(settings: Settings) =>
			{
				try
				{
					val classpathURLs = classpath.map(_.asURL).toList
					val bootClasspath = FileUtilities.pathSplit(settings.bootclasspath.value)
					val extraURLs =
						for(pathString <- bootClasspath if pathString.length > 0) yield
							(new java.io.File(pathString)).toURI.toURL
					ObjectRunner.run(classpathURLs ++ extraURLs, mainClass, options.toList)
					None
				}
				catch
				{
					case e: Exception => log.trace(e); Some("Error during run: " + e.getMessage)
				}
			}
		}
	}
	def apply(mainClassOption: Option[String], classpath: Iterable[Path], options: Seq[String], log: Logger) =
	{
		mainClassOption match
		{
			case Some(mainClass) => run(mainClass, classpath, options, log)
			case None => console(classpath, log)
		}
	}
	private def createSettings(log: Logger)(f: Settings => Option[String]) =
	{
		val command = new GenericRunnerCommand(Nil, message => log.error(message))
		if(command.ok)
			f(command.settings)
		else
			Some(command.usageMsg)
	}
	private def restoreTerminal(reader: interpreter.JLineReader)
	{
		val terminal = reader.consoleReader.getTerminal
		try
		{
			type UnixTerminal = { def restoreTerminal: Unit }
{'fraction_non_alphanumeric': 0.11519845111326234, 'fraction_numerical': 0.0002420135527589545, 'mean_word_length': 3.487513572204126, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 21, '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': '5139849', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1327, 'n_words': 321}