@@ -6,6 +6,8 @@ import scala.util.{ Try, Success, Failure }
66import reflect .ClassTag
77import core .Contexts ._
88import scala .annotation .tailrec
9+ import dotty .tools .io .{ Directory , Path }
10+
911// import annotation.unchecked
1012 // Dotty deviation: Imports take precedence over definitions in enclosing package
1113 // (Note that @unchecked is in scala, not annotation, so annotation.unchecked gives
@@ -20,6 +22,7 @@ object Settings {
2022 val ListTag = ClassTag (classOf [List [_]])
2123 val VersionTag = ClassTag (classOf [ScalaVersion ])
2224 val OptionTag = ClassTag (classOf [Option [_]])
25+ val DirectoryTag = ClassTag (classOf [Directory ])
2326
2427 class SettingsState (initialValues : Seq [Any ]) {
2528 private var values = ArrayBuffer (initialValues : _* )
@@ -158,6 +161,10 @@ object Settings {
158161 case Success (v) => update(v, args)
159162 case Failure (ex) => fail(ex.getMessage, args)
160163 }
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)
161168 case (_, Nil ) =>
162169 missingArg
163170 }
@@ -278,5 +285,8 @@ object Settings {
278285
279286 def OptionSetting [T : ClassTag ](name : String , descr : String ): Setting [Option [T ]] =
280287 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))
281291 }
282292}
0 commit comments