@@ -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 DirectoryJarTag = ClassTag (classOf [Path ])
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,11 +169,6 @@ object Settings {
161169 case Success (v) => update(v, args)
162170 case Failure (ex) => fail(ex.getMessage, args)
163171 }
164- case (DirectoryJarTag , arg :: args) =>
165- val path = Path (arg)
166- if (path.isDirectory) update(path, args)
167- else if (path.extension == " jar" ) update(path, args)
168- else fail(s " ' $arg' does not exist or is not a directory " , args)
169172 case (_, Nil ) =>
170173 missingArg
171174 }
@@ -275,6 +278,9 @@ object Settings {
275278 def PathSetting (name : String , descr : String , default : String ): Setting [String ] =
276279 publish(Setting (name, descr, default))
277280
281+ def PathSetting (name : String , helpArg : String , descr : String , default : String ): Setting [String ] =
282+ publish(Setting (name, descr, default, helpArg))
283+
278284 def PhasesSetting (name : String , descr : String , default : String = " " ): Setting [List [String ]] =
279285 publish(Setting (name, descr, if (default.isEmpty) Nil else List (default)))
280286
@@ -286,8 +292,5 @@ object Settings {
286292
287293 def OptionSetting [T : ClassTag ](name : String , descr : String ): Setting [Option [T ]] =
288294 publish(Setting (name, descr, None , propertyClass = Some (implicitly[ClassTag [T ]].runtimeClass)))
289-
290- def DirectoryJarSetting (name : String , helpArg : String , descr : String , default : Directory ): Setting [Path ] =
291- publish(Setting (name, descr, default, helpArg))
292295 }
293296}
0 commit comments