mirror of https://github.com/sbt/sbt.git
Switch to case-app 1.0.0-RC2, remove the need for two -- ...
...to specify user arguments with the launch command
This commit is contained in:
parent
bbe9ec5a21
commit
241cf866a0
|
|
@ -301,7 +301,7 @@ lazy val cli = project
|
|||
if (scalaVersion.value startsWith "2.10.")
|
||||
Seq()
|
||||
else
|
||||
Seq("com.github.alexarchambault" %% "case-app" % "1.0.0-RC1")
|
||||
Seq("com.github.alexarchambault" %% "case-app" % "1.0.0-RC2")
|
||||
},
|
||||
resourceGenerators in Compile += packageBin.in(bootstrap).in(Compile).map { jar =>
|
||||
Seq(jar)
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import shapeless.union.Union
|
|||
case class CoursierCommandHelper(
|
||||
command: CoursierCommandHelper.U
|
||||
) extends ArgsApp {
|
||||
def setRemainingArgs(remainingArgs: Seq[String]): Unit =
|
||||
command.unify.setRemainingArgs(remainingArgs)
|
||||
def setRemainingArgs(remainingArgs: Seq[String], extraArgs: Seq[String]): Unit =
|
||||
command.unify.setRemainingArgs(remainingArgs, extraArgs)
|
||||
def remainingArgs: Seq[String] =
|
||||
command.unify.remainingArgs
|
||||
def apply(): Unit =
|
||||
|
|
|
|||
|
|
@ -51,23 +51,32 @@ class IsolatedClassLoader(
|
|||
|
||||
}
|
||||
|
||||
// should be in case-app somehow
|
||||
trait ExtraArgsApp extends caseapp.core.DefaultArgsApp {
|
||||
private var remainingArgs1 = Seq.empty[String]
|
||||
private var extraArgs1 = Seq.empty[String]
|
||||
|
||||
override def setRemainingArgs(remainingArgs: Seq[String], extraArgs: Seq[String]): Unit = {
|
||||
remainingArgs1 = remainingArgs
|
||||
extraArgs1 = extraArgs
|
||||
}
|
||||
|
||||
override def remainingArgs: Seq[String] =
|
||||
remainingArgs1
|
||||
def extraArgs: Seq[String] =
|
||||
extraArgs1
|
||||
}
|
||||
|
||||
case class Launch(
|
||||
@Recurse
|
||||
options: LaunchOptions
|
||||
) extends App {
|
||||
) extends App with ExtraArgsApp {
|
||||
|
||||
val (rawDependencies, extraArgs) = {
|
||||
val idxOpt = Some(remainingArgs.indexOf("--")).filter(_ >= 0)
|
||||
idxOpt.fold((remainingArgs, Seq.empty[String])) { idx =>
|
||||
val (l, r) = remainingArgs.splitAt(idx)
|
||||
assert(r.nonEmpty)
|
||||
(l, r.tail)
|
||||
}
|
||||
}
|
||||
val userArgs = extraArgs
|
||||
|
||||
val helper = new Helper(
|
||||
options.common,
|
||||
rawDependencies ++ options.isolated.rawIsolated.map { case (_, dep) => dep }
|
||||
remainingArgs ++ options.isolated.rawIsolated.map { case (_, dep) => dep }
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -194,10 +203,10 @@ case class Launch(
|
|||
}
|
||||
|
||||
if (options.common.verbosityLevel >= 2)
|
||||
Helper.errPrintln(s"Launching $mainClass0 ${extraArgs.mkString(" ")}")
|
||||
Helper.errPrintln(s"Launching $mainClass0 ${userArgs.mkString(" ")}")
|
||||
else if (options.common.verbosityLevel == 1)
|
||||
Helper.errPrintln(s"Launching")
|
||||
|
||||
Thread.currentThread().setContextClassLoader(loader)
|
||||
method.invoke(null, extraArgs.toArray)
|
||||
method.invoke(null, userArgs.toArray)
|
||||
}
|
||||
Loading…
Reference in New Issue