@@ -6,7 +6,7 @@ import scala.util.{ Try, Success, Failure }
66import reflect .ClassTag
77import core .Contexts ._
88import scala .annotation .tailrec
9- import dotty .tools .io .{ Directory , Path }
9+ import dotty .tools .io .{ Directory , File , Path }
1010
1111// import annotation.unchecked
1212 // Dotty deviation: Imports take precedence over definitions in enclosing package
@@ -22,7 +22,6 @@ object Settings {
2222 val ListTag = ClassTag (classOf [List [_]])
2323 val VersionTag = ClassTag (classOf [ScalaVersion ])
2424 val OptionTag = ClassTag (classOf [Option [_]])
25- val DirectoryTag = ClassTag (classOf [Directory ])
2625
2726 class SettingsState (initialValues : Seq [Any ]) {
2827 private [this ] var values = ArrayBuffer (initialValues : _* )
@@ -141,6 +140,15 @@ object Settings {
141140 else if (! choices.contains(argRest))
142141 fail(s " $arg is not a valid choice for $name" , args)
143142 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+ }
144152 case (StringTag , arg2 :: args2) =>
145153 update(arg2, args2)
146154 case (IntTag , arg2 :: args2) =>
@@ -161,10 +169,6 @@ object Settings {
161169 case Success (v) => update(v, args)
162170 case Failure (ex) => fail(ex.getMessage, args)
163171 }
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)
168172 case (_, Nil ) =>
169173 missingArg
170174 }
@@ -274,6 +278,9 @@ object Settings {
274278 def PathSetting (name : String , descr : String , default : String ): Setting [String ] =
275279 publish(Setting (name, descr, default))
276280
281+ def PathSetting (name : String , helpArg : String , descr : String , default : String ): Setting [String ] =
282+ publish(Setting (name, descr, default, helpArg))
283+
277284 def PhasesSetting (name : String , descr : String , default : String = " " ): Setting [List [String ]] =
278285 publish(Setting (name, descr, if (default.isEmpty) Nil else List (default)))
279286
@@ -285,8 +292,5 @@ object Settings {
285292
286293 def OptionSetting [T : ClassTag ](name : String , descr : String ): Setting [Option [T ]] =
287294 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))
291295 }
292296}
0 commit comments