Skip to content

Commit fd9a3d5

Browse files
committed
Allow choice settings to take separate arguments
Previously it was `-foo:bar` for a choice setting but `-foo bar` for a string setting. It does not really make sense to demand a difference. The `:` syntax is required only for multi-string settings. Fow now, we allow either a `:` or a space for choice settings.
1 parent 028c3ba commit fd9a3d5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/src/dotty/tools/dotc/config/Settings.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ object Settings {
135135
case (ListTag, _) =>
136136
if (argRest.isEmpty) missingArg
137137
else update((argRest split ",").toList, args)
138-
case (StringTag, _) if choices.nonEmpty =>
139-
if (argRest.isEmpty) missingArg
140-
else if (!choices.contains(argRest))
138+
case (StringTag, _) if choices.nonEmpty && argRest.nonEmpty =>
139+
if (!choices.contains(argRest))
141140
fail(s"$arg is not a valid choice for $name", args)
142141
else update(argRest, args)
142+
case (StringTag, arg2 :: args2) =>
143+
if (arg2 startsWith "-") missingArg
144+
else update(arg2, args2)
143145
case (OutputTag, arg :: args) =>
144146
val path = Directory(arg)
145147
val isJar = path.extension == "jar"
@@ -149,9 +151,6 @@ object Settings {
149151
val output = if (isJar) JarArchive.create(path) else new PlainDirectory(path)
150152
update(output, args)
151153
}
152-
case (StringTag, arg2 :: args2) =>
153-
if (arg2 startsWith "-") missingArg
154-
else update(arg2, args2)
155154
case (IntTag, arg2 :: args2) =>
156155
try {
157156
val x = arg2.toInt

0 commit comments

Comments
 (0)