Merge pull request #7239 from eed3si9n/wip/alias_new

Add init as an alias to new
This commit is contained in:
eugene yokota 2023-05-07 14:40:49 -04:00 committed by GitHub
commit ef81cd00de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 9 deletions

View File

@ -17,6 +17,7 @@ object BasicCommandStrings {
val Shutdown: String = "shutdown"
val Quit: String = "quit"
val TemplateCommand: String = "new"
val TemplateCommandAlias: String = "init"
val Cancel: String = "cancel"
/** The command name to terminate the program.*/

View File

@ -71,7 +71,7 @@ private[sbt] object xMain {
.filterNot(_ == DashDashServer)
val isClient: String => Boolean = cmd => (cmd == JavaClient) || (cmd == DashDashClient)
val isBsp: String => Boolean = cmd => (cmd == "-bsp") || (cmd == "--bsp")
val isNew: String => Boolean = cmd => (cmd == "new")
val isNew: String => Boolean = cmd => (cmd == "new") || (cmd == "init")
lazy val isServer = !userCommands.exists(c => isBsp(c) || isClient(c))
// keep this lazy to prevent project directory created prematurely
lazy val bootServerSocket = if (isServer) getSocketOrExit(configuration) match {
@ -108,7 +108,7 @@ private[sbt] object xMain {
.initialState(
rebasedConfig,
Seq(defaults, early),
runEarly(DefaultsCommand) :: runEarly(InitCommand) :: BootCommand :: Nil
runEarly(DefaultsCommand) :: runEarly("error") :: runEarly(InitCommand) :: BootCommand :: Nil
)
.put(BasicKeys.detachStdio, detachStdio)
StandardMain.runManaged(state)
@ -289,7 +289,7 @@ object StandardMain {
import sbt.BasicCommandStrings._
import sbt.BasicCommands._
import sbt.CommandUtil._
import sbt.TemplateCommandUtil.templateCommand
import sbt.TemplateCommandUtil.{ templateCommandAlias, templateCommand }
import sbt.internal.CommandStrings._
import sbt.internal.util.complete.DefaultParsers._
@ -311,6 +311,7 @@ object BuiltinCommands {
settingsCommand,
loadProject,
templateCommand,
templateCommandAlias,
projects,
project,
set,

View File

@ -11,7 +11,6 @@ import java.lang.reflect.InvocationTargetException
import java.nio.file.Path
import java.io.File
import sbt.BasicCommandStrings.TerminateAction
import sbt.SlashSyntax0._
import sbt.io._, syntax._
import sbt.util._
@ -24,8 +23,10 @@ import sbt.internal.inc.classpath.ClasspathUtil
import BasicCommandStrings._, BasicKeys._
private[sbt] object TemplateCommandUtil {
def templateCommand: Command =
Command(TemplateCommand, templateBrief, templateDetailed)(_ => templateCommandParser)(
def templateCommand: Command = templateCommand0(TemplateCommand)
def templateCommandAlias: Command = templateCommand0("init")
private def templateCommand0(command: String): Command =
Command(command, templateBrief, templateDetailed)(_ => templateCommandParser)(
runTemplate
)
@ -288,7 +289,7 @@ libraryDependencies += (toolkitTest % Test)
}
private def typelevelToolkitTemplate(): Unit = {
val defaultTypelevelToolkitV = "0.0.7"
val defaultTypelevelToolkitV = "0.0.8"
val scalaV = ask("Scala version", defaultScalaV)
val toolkitV = ask("Typelevel Toolkit version", defaultTypelevelToolkitV)
val content = s"""

View File

@ -1,7 +1,7 @@
scalaSource in Configurations.Compile := (sourceDirectory.value / " scala test ")
javaSource in Configurations.Compile := (sourceDirectory.value / " java test ")
TaskKey[Unit]("init") := {
TaskKey[Unit]("init0") := {
val ss = (scalaSource in Configurations.Compile).value
val js = ( javaSource in Configurations.Compile).value
import IO._

View File

@ -1,2 +1,2 @@
> init
> init0
> run