/
GenericRunnerSettings.scala
67 lines (56 loc) · 1.52 KB
/
GenericRunnerSettings.scala
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package scala.tools.nsc
import java.net.URL
import scala.tools.util.PathResolver
class GenericRunnerSettings(error: String => Unit) extends Settings(error) {
lazy val classpathURLs: Seq[URL] = {
val registry = new CloseableRegistry
try {
new PathResolver(this, registry).resultAsURLs
} finally {
registry.close()
}
}
val howtorun =
ChoiceSetting(
"-howtorun",
"how",
"how to run the specified code",
List("object", "script", "jar", "repl", "guess"),
"guess")
val loadfiles =
MultiStringSetting(
"-I",
"file",
"load a file line-by-line")
val pastefiles =
MultiStringSetting(
"-i",
"file",
"paste a file")
val execute =
StringSetting(
"-e",
"string",
"execute a single command",
"")
val save =
BooleanSetting(
"-save",
"save the compiled script (assumes the code is a script)") withAbbreviation "-savecompiled"
val nc = BooleanSetting(
"-nc",
"do not use the fsc compilation daemon") withAbbreviation "-nocompdaemon" withPostSetHook((x: BooleanSetting) => {_useCompDaemon = !x.value })
private[this] var _useCompDaemon = true
def useCompDaemon: Boolean = _useCompDaemon
}