From 3cc6245389bea0646c07b8a4f76047d492b386f7 Mon Sep 17 00:00:00 2001 From: Lex Spoon Date: Tue, 7 Mar 2006 11:08:46 +0000 Subject: allow the interpreter to be called with a file ... allow the interpreter to be called with a file on the command line --- src/compiler/scala/tools/nsc/CompilerCommand.scala | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/compiler/scala/tools/nsc/CompilerCommand.scala') diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index 71707dc3c5..ddf3165ac3 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -16,6 +16,12 @@ class CompilerCommand(arguments: List[String], error: String => unit, interactiv /** The applicable settings */ val settings: Settings = new Settings(error); + /** The name of the command */ + val cmdName = "scalac"; + + /** The file extension of files that the compiler can process */ + val fileEnding = ".scala"; + /** A message explaining usage and options */ def usageMsg: String = { val helpSyntaxColumnWidth: int = @@ -29,12 +35,12 @@ class CompilerCommand(arguments: List[String], error: String => unit, interactiv } settings.allSettings .map(setting => - format(setting.helpSyntax) + " " + setting.helpDescription) + format(setting.helpSyntax) + " " + setting.helpDescription) .mkString( - "Usage: scalac \n" + - "where possible options include: \n ", - "\n ", - "\n"); + "Usage: " + cmdName + " \n" + + "where possible options include: \n ", + "\n ", + "\n"); } // initialization @@ -44,17 +50,17 @@ class CompilerCommand(arguments: List[String], error: String => unit, interactiv val args0 = args; if (args.head.startsWith("-")) { if (interactive) { - error("no options can be given in interactive mode"); - ok = false + error("no options can be given in interactive mode"); + ok = false } else { - for (val setting <- settings.allSettings) + for (val setting <- settings.allSettings) args = setting.tryToSet(args); - if (args eq args0) { - error("unknown option: '" + args.head + "'"); - ok = false - } + if (args eq args0) { + error("unknown option: '" + args.head + "'"); + ok = false + } } - } else if (args.head.endsWith(".scala")) { + } else if (args.head.endsWith(fileEnding)) { fs = args.head :: fs; args = args.tail } else { -- cgit v1.2.3