@@ -6,7 +6,7 @@ import scala.util.{ Try, Success, Failure }
6
6
import reflect .ClassTag
7
7
import core .Contexts ._
8
8
import scala .annotation .tailrec
9
- import dotty .tools .io .{ Directory , Path }
9
+ import dotty .tools .io .{ Directory , File , Path }
10
10
11
11
// import annotation.unchecked
12
12
// Dotty deviation: Imports take precedence over definitions in enclosing package
@@ -22,7 +22,6 @@ object Settings {
22
22
val ListTag = ClassTag (classOf [List [_]])
23
23
val VersionTag = ClassTag (classOf [ScalaVersion ])
24
24
val OptionTag = ClassTag (classOf [Option [_]])
25
- val DirectoryTag = ClassTag (classOf [Directory ])
26
25
27
26
class SettingsState (initialValues : Seq [Any ]) {
28
27
private [this ] var values = ArrayBuffer (initialValues : _* )
@@ -141,6 +140,15 @@ object Settings {
141
140
else if (! choices.contains(argRest))
142
141
fail(s " $arg is not a valid choice for $name" , args)
143
142
else update(argRest, args)
143
+ case (StringTag , arg :: args) if name == " -d" =>
144
+ Path (arg) match {
145
+ case _ : Directory =>
146
+ update(arg, args)
147
+ case p if p.extension == " jar" =>
148
+ update(arg, args)
149
+ case _ =>
150
+ fail(s " ' $arg' does not exist or is not a directory " , args)
151
+ }
144
152
case (StringTag , arg2 :: args2) =>
145
153
update(arg2, args2)
146
154
case (IntTag , arg2 :: args2) =>
@@ -161,10 +169,6 @@ object Settings {
161
169
case Success (v) => update(v, args)
162
170
case Failure (ex) => fail(ex.getMessage, args)
163
171
}
164
- case (DirectoryTag , arg :: args) =>
165
- val path = Path (arg)
166
- if (path.isDirectory) update(Directory (path), args)
167
- else fail(s " ' $arg' does not exist or is not a directory " , args)
168
172
case (_, Nil ) =>
169
173
missingArg
170
174
}
@@ -274,6 +278,9 @@ object Settings {
274
278
def PathSetting (name : String , descr : String , default : String ): Setting [String ] =
275
279
publish(Setting (name, descr, default))
276
280
281
+ def PathSetting (name : String , helpArg : String , descr : String , default : String ): Setting [String ] =
282
+ publish(Setting (name, descr, default, helpArg))
283
+
277
284
def PhasesSetting (name : String , descr : String , default : String = " " ): Setting [List [String ]] =
278
285
publish(Setting (name, descr, if (default.isEmpty) Nil else List (default)))
279
286
@@ -285,8 +292,5 @@ object Settings {
285
292
286
293
def OptionSetting [T : ClassTag ](name : String , descr : String ): Setting [Option [T ]] =
287
294
publish(Setting (name, descr, None , propertyClass = Some (implicitly[ClassTag [T ]].runtimeClass)))
288
-
289
- def DirectorySetting (name : String , helpArg : String , descr : String , default : Directory ): Setting [Directory ] =
290
- publish(Setting (name, descr, default, helpArg))
291
295
}
292
296
}
0 commit comments