summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-18 19:06:22 +0000
committerPaul Phillips <paulp@improving.org>2011-03-18 19:06:22 +0000
commit0554c378653c47aefaabe48b0ef568f952d1695b (patch)
treea9c8b1e004efc67a2a7cd4772ae08013e99b108a /src/compiler/scala/tools/nsc/GenericRunnerCommand.scala
parentf3b970b28cf640904fe0d340f9eb7de37514cb67 (diff)
downloadscala-0554c378653c47aefaabe48b0ef568f952d1695b.tar.gz
scala-0554c378653c47aefaabe48b0ef568f952d1695b.tar.bz2
scala-0554c378653c47aefaabe48b0ef568f952d1695b.zip
Improved the error message when one gives inval...
Improved the error message when one gives invalid options to scala. Similar improvements for scalac/fsc/etc has to wait. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/GenericRunnerCommand.scala')
-rw-r--r--src/compiler/scala/tools/nsc/GenericRunnerCommand.scala21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala
index c8e86a752d..68689a4109 100644
--- a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala
+++ b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala
@@ -27,8 +27,8 @@ extends CompilerCommand(args, settings) {
/** thingToRun: What to run. If it is None, then the interpreter should be started
* arguments: Arguments to pass to the object or script to run
*/
- val (thingToRun, arguments) = {
- val (_, remaining) = settings.processArguments(args, false)
+ val (_ok, thingToRun, arguments) = {
+ val (ok, remaining) = settings.processArguments(args, false)
val mainClass =
if (settings.jarfile.isDefault) None
else new io.Jar(settings.jarfile.value).mainClass
@@ -37,17 +37,23 @@ extends CompilerCommand(args, settings) {
// Otherwise, the first remaining argument is the program to run, and the rest
// of the arguments go to it. If remaining is empty, we'll start the repl.
mainClass match {
- case Some(name) => (Some(name), remaining)
- case _ => (remaining.headOption, remaining drop 1)
+ case Some(name) => (ok, Some(name), remaining)
+ case _ => (ok, remaining.headOption, remaining drop 1)
}
}
+ override def ok = _ok
- override def usageMsg ="""
+ private def interpolate(s: String) = s.trim.replaceAll("@cmd@", cmdName).replaceAll("@compileCmd@", compCmdName) + "\n"
+
+ def shortUsageMsg = interpolate("""
Usage: @cmd@ <options> [<script|class|object> <arguments>]
or @cmd@ <options> [-jar <jarfile> <arguments>]
+ or @cmd@ -help
-All options to @compileCmd@ are allowed. See @compileCmd@ -help.
+All options to @compileCmd@ are also allowed. See @compileCmd@ -help.
+ """)
+ override def usageMsg = shortUsageMsg + "\n" + interpolate("""
The first given argument other than options to @cmd@ designates
what to run. Runnable targets are:
@@ -74,6 +80,5 @@ A file argument will be run as a scala script unless it contains only top
level classes and objects, and exactly one runnable main method. In that
case the file will be compiled and the main method invoked. This provides
a bridge between scripts and standard scala source.
-
- """.replaceAll("@cmd@", cmdName).replaceAll("@compileCmd@", compCmdName)
+ """) + "\n"
}