Skip to content

Commit f4b7d43

Browse files
authored
Merge pull request scala#6499 from taku0/topic/double-hyphen-options
Support JEP 293 style long command-line options
2 parents 24ec8f1 + a9812ac commit f4b7d43

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

src/compiler/scala/tools/nsc/GenericRunnerSettings.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class GenericRunnerSettings(error: String => Unit) extends Settings(error) {
1717
"how",
1818
"how to run the specified code",
1919
List("object", "script", "jar", "repl", "guess"),
20-
"guess")
20+
"guess") withAbbreviation "--how-to-run"
2121

2222
val loadfiles =
2323
MultiStringSetting(
@@ -41,11 +41,11 @@ class GenericRunnerSettings(error: String => Unit) extends Settings(error) {
4141
val save =
4242
BooleanSetting(
4343
"-save",
44-
"save the compiled script (assumes the code is a script)") withAbbreviation "-savecompiled"
44+
"save the compiled script (assumes the code is a script)") withAbbreviation "-savecompiled" withAbbreviation "--save"
4545

4646
val nc = BooleanSetting(
4747
"-nc",
48-
"do not use the legacy fsc compilation daemon").withAbbreviation("-nocompdaemon")
48+
"do not use the legacy fsc compilation daemon").withAbbreviation("-nocompdaemon").withAbbreviation("--no-compilation-daemon")
4949
.withDeprecationMessage("scripts use cold compilation by default; use -Yscriptrunner for custom behavior")
5050
.withPostSetHook { x: BooleanSetting => Yscriptrunner.value = if (x) "default" else "resident" }
5151
}

src/compiler/scala/tools/nsc/fsc/FscSettings.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ class FscSettings(error: String => Unit) extends Settings(error) {
1717
disable(resident)
1818
}
1919

20-
val currentDir = StringSetting ("-current-dir", "path", "Base directory for resolving relative paths", "").internalOnly()
21-
val reset = BooleanSetting("-reset", "Reset compile server caches")
22-
val shutdown = BooleanSetting("-shutdown", "Shutdown compile server")
23-
val server = StringSetting ("-server", "hostname:portnumber", "Specify compile server socket", "")
20+
val currentDir = StringSetting ("-current-dir", "path", "Base directory for resolving relative paths", "").internalOnly() withAbbreviation "--current-directory"
21+
val reset = BooleanSetting("-reset", "Reset compile server caches") withAbbreviation "--reset"
22+
val shutdown = BooleanSetting("-shutdown", "Shutdown compile server") withAbbreviation "--shutdown"
23+
val server = StringSetting ("-server", "hostname:portnumber", "Specify compile server socket", "") withAbbreviation "--server"
2424
val port = IntSetting ("-port", "Search and start compile server in given port only",
25-
0, Some((0, Int.MaxValue)), (_: String) => None)
26-
val preferIPv4 = BooleanSetting("-ipv4", "Use IPv4 rather than IPv6 for the server socket")
25+
0, Some((0, Int.MaxValue)), (_: String) => None) withAbbreviation "--port"
26+
val preferIPv4 = BooleanSetting("-ipv4", "Use IPv4 rather than IPv6 for the server socket") withAbbreviation "--ipv4"
2727
val idleMins = IntSetting ("-max-idle", "Set idle timeout in minutes for fsc (use 0 for no timeout)",
28-
30, Some((0, Int.MaxValue)), (_: String) => None)
28+
30, Some((0, Int.MaxValue)), (_: String) => None) withAbbreviation "--max-idle"
2929

3030
// For improved help output, separating fsc options from the others.
3131
def fscSpecific = Set[Settings#Setting](

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ trait ScalaSettings extends AbsScalaSettings
4444

4545
val jvmargs = PrefixSetting("-J<flag>", "-J", "Pass <flag> directly to the runtime system.")
4646
val defines = PrefixSetting("-Dproperty=value", "-D", "Pass -Dproperty=value directly to the runtime system.")
47-
/*val toolcp =*/ PathSetting("-toolcp", "Add to the runner classpath.", "")
48-
val nobootcp = BooleanSetting("-nobootcp", "Do not use the boot classpath for the scala jars.")
47+
/*val toolcp =*/ PathSetting("-toolcp", "Add to the runner classpath.", "") withAbbreviation "--tool-class-path"
48+
val nobootcp = BooleanSetting("-nobootcp", "Do not use the boot classpath for the scala jars.") withAbbreviation "--no-boot-class-path"
4949

5050
/**
5151
* Standard settings
5252
*/
5353
// argfiles is only for the help message
5454
/*val argfiles = */ BooleanSetting ("@<file>", "A text file containing compiler arguments (options and source files)")
55-
val classpath = PathSetting ("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"
55+
val classpath = PathSetting ("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp" withAbbreviation "--class-path"
5656
val d = OutputSetting (outputDirs, ".")
57-
val nospecialization = BooleanSetting ("-no-specialization", "Ignore @specialize annotations.")
57+
val nospecialization = BooleanSetting ("-no-specialization", "Ignore @specialize annotations.") withAbbreviation "--no-specialization"
5858

5959
// Would be nice to build this dynamically from scala.languageFeature.
6060
// The two requirements: delay error checking until you have symbols, and let compiler command build option-specific help.
@@ -74,7 +74,7 @@ trait ScalaSettings extends AbsScalaSettings
7474
helpArg = "feature",
7575
descr = description,
7676
domain = languageFeatures
77-
)
77+
) withAbbreviation "--language"
7878
}
7979
val release = StringSetting("-release", "release", "Compile for a specific version of the Java platform. Supported targets: 6, 7, 8, 9", "").withPostSetHook { (value: StringSetting) =>
8080
if (value.value != "" && !scala.util.Properties.isJavaAtLeast("9")) {
@@ -83,7 +83,7 @@ trait ScalaSettings extends AbsScalaSettings
8383
// TODO validate numeric value
8484
// TODO validate release <= java.specification.version
8585
}
86-
}
86+
} withAbbreviation "--release"
8787
def releaseValue: Option[String] = Option(release.value).filter(_ != "")
8888

8989
/*

src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,32 @@ trait StandardScalaSettings {
1818

1919
/** Path related settings.
2020
*/
21-
val bootclasspath = PathSetting ("-bootclasspath", "Override location of bootstrap class files.", Defaults.scalaBootClassPath)
21+
val bootclasspath = PathSetting ("-bootclasspath", "Override location of bootstrap class files.", Defaults.scalaBootClassPath) withAbbreviation "--boot-class-path"
2222
val classpath: PathSetting // is mutated directly in various places (thus inspiring this very effort)
2323
val d: OutputSetting // depends on mutable OutputDirs class
24-
val extdirs = PathSetting ("-extdirs", "Override location of installed extensions.", Defaults.scalaExtDirs)
25-
val javabootclasspath = PathSetting ("-javabootclasspath", "Override java boot classpath.", Defaults.javaBootClassPath)
26-
val javaextdirs = PathSetting ("-javaextdirs", "Override java extdirs classpath.", Defaults.javaExtDirs)
27-
val sourcepath = PathSetting ("-sourcepath", "Specify location(s) of source files.", "") // Defaults.scalaSourcePath
24+
val extdirs = PathSetting ("-extdirs", "Override location of installed extensions.", Defaults.scalaExtDirs) withAbbreviation "--extension-directories"
25+
val javabootclasspath = PathSetting ("-javabootclasspath", "Override java boot classpath.", Defaults.javaBootClassPath) withAbbreviation "--java-boot-class-path"
26+
val javaextdirs = PathSetting ("-javaextdirs", "Override java extdirs classpath.", Defaults.javaExtDirs) withAbbreviation "--java-extension-directories"
27+
val sourcepath = PathSetting ("-sourcepath", "Specify location(s) of source files.", "") withAbbreviation "--source-path" // Defaults.scalaSourcePath
2828

2929
/** Other settings.
3030
*/
31-
val dependencyfile = StringSetting ("-dependencyfile", "file", "Set dependency tracking file.", ".scala_dependencies")
32-
val deprecation = BooleanSetting ("-deprecation", "Emit warning and location for usages of deprecated APIs.")
33-
val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding)
34-
val explaintypes = BooleanSetting ("-explaintypes", "Explain type errors in more detail.")
35-
val feature = BooleanSetting ("-feature", "Emit warning and location for usages of features that should be imported explicitly.")
31+
val dependencyfile = StringSetting ("-dependencyfile", "file", "Set dependency tracking file.", ".scala_dependencies") withAbbreviation "--dependency-file"
32+
val deprecation = BooleanSetting ("-deprecation", "Emit warning and location for usages of deprecated APIs.") withAbbreviation "--deprecation"
33+
val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding) withAbbreviation "--encoding"
34+
val explaintypes = BooleanSetting ("-explaintypes", "Explain type errors in more detail.") withAbbreviation "--explain-types"
35+
val feature = BooleanSetting ("-feature", "Emit warning and location for usages of features that should be imported explicitly.") withAbbreviation "--feature"
3636
val g = ChoiceSetting ("-g", "level", "Set level of generated debugging info.", List("none", "source", "line", "vars", "notailcalls"), "vars")
37-
val help = BooleanSetting ("-help", "Print a synopsis of standard options")
38-
val nowarn = BooleanSetting ("-nowarn", "Generate no warnings.")
37+
val help = BooleanSetting ("-help", "Print a synopsis of standard options") withAbbreviation "--help"
38+
val nowarn = BooleanSetting ("-nowarn", "Generate no warnings.") withAbbreviation "--no-warnings"
3939
val optimise: BooleanSetting // depends on post hook which mutates other settings
40-
val print = BooleanSetting ("-print", "Print program with Scala-specific features removed.")
40+
val print = BooleanSetting ("-print", "Print program with Scala-specific features removed.") withAbbreviation "--print"
4141
val target = ChoiceSettingForcedDefault ("-target", "target", "Target platform for object files. All JVM 1.5 - 1.7 targets are deprecated.",
42-
List("jvm-1.5", "jvm-1.6", "jvm-1.7", "jvm-1.8"), "jvm-1.8")
43-
val unchecked = BooleanSetting ("-unchecked", "Enable additional warnings where generated code depends on assumptions.")
44-
val uniqid = BooleanSetting ("-uniqid", "Uniquely tag all identifiers in debugging output.")
45-
val usejavacp = BooleanSetting ("-usejavacp", "Utilize the java.class.path in classpath resolution.")
46-
val usemanifestcp = BooleanSetting ("-usemanifestcp", "Utilize the manifest in classpath resolution.")
47-
val verbose = BooleanSetting ("-verbose", "Output messages about what the compiler is doing.")
48-
val version = BooleanSetting ("-version", "Print product version and exit.")
42+
List("jvm-1.5", "jvm-1.6", "jvm-1.7", "jvm-1.8"), "jvm-1.8") withAbbreviation "--target"
43+
val unchecked = BooleanSetting ("-unchecked", "Enable additional warnings where generated code depends on assumptions.") withAbbreviation "--unchecked"
44+
val uniqid = BooleanSetting ("-uniqid", "Uniquely tag all identifiers in debugging output.") withAbbreviation "--unique-id"
45+
val usejavacp = BooleanSetting ("-usejavacp", "Utilize the java.class.path in classpath resolution.") withAbbreviation "--use-java-class-path"
46+
val usemanifestcp = BooleanSetting ("-usemanifestcp", "Utilize the manifest in classpath resolution.") withAbbreviation "--use-manifest-class-path"
47+
val verbose = BooleanSetting ("-verbose", "Output messages about what the compiler is doing.") withAbbreviation "--verbose"
48+
val version = BooleanSetting ("-version", "Print product version and exit.") withAbbreviation "--version"
4949
}

src/scaladoc/scala/tools/nsc/doc/Settings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
223223
docDiagramsMaxNormalClasses, docDiagramsMaxImplicitClasses,
224224
docNoPrefixes, docNoLinkWarnings, docRawOutput, docSkipPackages,
225225
docExpandAllTypes, docGroups, docNoJavaComments
226-
)
226+
).map(s => s.withAbbreviation("-" + s.name))
227227
val isScaladocSpecific: String => Boolean = scaladocSpecific map (_.name)
228228

229229
override def isScaladoc = true

0 commit comments

Comments
 (0)