Add init as an alias to new

This commit is contained in:
Eugene Yokota 2023-05-07 13:46:43 -04:00
parent 648815ca3b
commit 731af0173c
5 changed files with 11 additions and 8 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
)

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