@@ -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 , File , Path }
9+ import dotty .tools .io .{ AbstractFile , Directory , JarArchive , PlainDirectory , File , Path }
1010
1111// import annotation.unchecked
1212 // Dotty deviation: Imports take precedence over definitions in enclosing package
@@ -22,6 +22,7 @@ object Settings {
2222 val ListTag = ClassTag (classOf [List [_]])
2323 val VersionTag = ClassTag (classOf [ScalaVersion ])
2424 val OptionTag = ClassTag (classOf [Option [_]])
25+ val OutputTag = ClassTag (classOf [AbstractFile ])
2526
2627 class SettingsState (initialValues : Seq [Any ]) {
2728 private [this ] var values = ArrayBuffer (initialValues : _* )
@@ -140,14 +141,14 @@ object Settings {
140141 else if (! choices.contains(argRest))
141142 fail(s " $arg is not a valid choice for $name" , args)
142143 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)
144+ case (OutputTag , arg :: args) =>
145+ val path = Directory (arg)
146+ val isJar = path.extension == " jar "
147+ if ( ! isJar && ! path.isDirectory )
148+ fail( s " ' $arg ' does not exist or is not a directory or . jar file " , args)
149+ else {
150+ val output = if (isJar) JarArchive .create(path) else new PlainDirectory (path)
151+ update(output , args)
151152 }
152153 case (StringTag , arg2 :: args2) =>
153154 update(arg2, args2)
@@ -275,11 +276,14 @@ object Settings {
275276 def MultiStringSetting (name : String , helpArg : String , descr : String ): Setting [List [String ]] =
276277 publish(Setting (name, descr, Nil , helpArg))
277278
279+ def OutputSetting (name : String , helpArg : String , descr : String , default : AbstractFile ): Setting [AbstractFile ] =
280+ publish(Setting (name, descr, default, helpArg))
281+
278282 def PathSetting (name : String , descr : String , default : String ): Setting [String ] =
279283 publish(Setting (name, descr, default))
280284
281285 def PathSetting (name : String , helpArg : String , descr : String , default : String ): Setting [String ] =
282- publish(Setting (name, descr, default, helpArg))
286+ publish(Setting (name, descr, default, helpArg))
283287
284288 def PhasesSetting (name : String , descr : String , default : String = " " ): Setting [List [String ]] =
285289 publish(Setting (name, descr, if (default.isEmpty) Nil else List (default)))
0 commit comments