blob: 7fbf0d8f21ab94b31bebc788f2904c0b9a1c3fb8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package scala.tools.nsc
/** A command for ScriptRunner */
class GenericRunnerCommand(allargs: List[String], error: String=>Unit) {
def this(allargs: List[String]) = this(allargs, str:String => {
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 (val setting <- settings.allSettings)
args = setting.tryToSet(args)
if (args eq args0) {
error("unknown option: '" + args.head + "'")
ok = false
}
}
if(!args.isEmpty) {
thingToRun = Some(args.head)
arguments = args.tail
}
}
parseArguments
val usageMessage = {
"scala [ <compiler-option> | -howtorun:how ]... [<torun> <arguments>]\n" +
"\n" +
"<compiler-option>'s are as for scalac; see scalac -help.\n" +
"<torun>, if present, is an object or script file to run.\n" +
"If no <torun> is present, run an interactive interpreter.\n" +
"-howtorun allows explicitly specifying how to run <torun>:\n" +
" script: it is a script file\n" +
" object: it is an object name\n" +
" guess: (the default) try to guess\n"
}
}
|