package scala.tools.nsc
import java.net.URL
import util.ScalaClassLoader
import java.lang.reflect.InvocationTargetException
import util.Exceptional.unwrap
object ObjectRunner {
def classExists(urls: List[URL], objectName: String): Boolean =
ScalaClassLoader.classExists(urls, objectName)
def run(urls: List[URL], objectName: String, arguments: Seq[String]) {
(ScalaClassLoader fromURLs urls).run(objectName, arguments)
}
def runAndCatch(urls: List[URL], objectName: String, arguments: Seq[String]): Either[Throwable, Boolean] = {
try { run(urls, objectName, arguments) ; Right(true) }
catch { case e => Left(unwrap(e)) }
}
}