/* NSC -- new Scala compiler * Copyright 2007 LAMP/EPFL * @author Lex Spoon */ // $Id$ package scala.tools.nsc /** A command for ScriptRunner */ class GenericRunnerCommand(allargs: List[String], error: String => Unit) { def this(allargs: List[String]) = this(allargs, str => Console.println("Error: " + str)) /** Settings specified by this command */ val settings = new GenericRunnerSettings(error) /** Whether the command was parsed correctly */ var ok = true /** What to run. If it is None, then the interpreter should be started */ var thingToRun: Option[String] = None /** Arguments to pass to the object or script to run */ var arguments: List[String] = Nil private def parseArguments: Unit = { var args = allargs while (!args.isEmpty && ok && args.head.startsWith("-")) { val args0 = args for (setting <- settings.allSettings) if (args eq args0) args = setting.tryToSet(args) if (args eq args0) { error("bad option: '" + args.head + "'") ok = false } } if (!args.isEmpty) { thingToRun = Some(args.head) arguments = args.tail } } parseArguments val usageMessage = { "scala [