Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for new command #2202

Merged
merged 14 commits into from Jun 20, 2023
Merged
1 change: 1 addition & 0 deletions build.sc
Expand Up @@ -781,6 +781,7 @@ trait Cli extends SbtModule with ProtoBuildModule with CliLaunchers
Deps.coursierLauncher,
Deps.coursierProxySetup,
Deps.coursierPublish.exclude((organization, "config_2.13")),
Deps.giter8,
Deps.jimfs, // scalaJsEnvNodeJs pulls jimfs:1.1, whose class path seems borked (bin compat issue with the guava version it depends on)
Deps.jniUtils,
Deps.jsoniterCore,
Expand Down
Expand Up @@ -42,6 +42,7 @@ class ScalaCliCommands(
new HelpCmd(help),
installcompletions.InstallCompletions,
installhome.InstallHome,
`new`.New,
repl.Repl,
package0.Package,
pgp.PgpPull,
Expand Down
18 changes: 18 additions & 0 deletions modules/cli/src/main/scala/scala/cli/commands/new/New.scala
@@ -0,0 +1,18 @@
package scala.cli.commands.`new`

import scala.cli.commands.ScalaCommand
import scala.cli.commands.shared.HelpCommandGroup
import scala.build.Logger
import caseapp.core.RemainingArgs
import giter8.Giter8

object New extends ScalaCommand[NewOptions] {
override def group: String = HelpCommandGroup.Main.toString

override def scalaSpecificationLevel = SpecificationLevel.IMPLEMENTATION
zetashift marked this conversation as resolved.
Show resolved Hide resolved

override def runCommand(options: NewOptions, remainingArgs: RemainingArgs, logger: Logger): Unit =
val inputArgs = remainingArgs.remaining
Giter8.run(inputArgs.toArray)
()
zetashift marked this conversation as resolved.
Show resolved Hide resolved
}
25 changes: 25 additions & 0 deletions modules/cli/src/main/scala/scala/cli/commands/new/NewOptions.scala
@@ -0,0 +1,25 @@
package scala.cli.commands.`new`

import caseapp.*
import scala.cli.commands.shared.*

@HelpMessage(NewOptions.newMessage, "", NewOptions.detailedNewMessage)
final case class NewOptions(
@Recurse
shared: SharedOptions = SharedOptions()
) extends HasSharedOptions
zetashift marked this conversation as resolved.
Show resolved Hide resolved

object NewOptions {
implicit lazy val parser: Parser[NewOptions] = Parser.derive
implicit lazy val help: Help[NewOptions] = Help.derive
val cmdName = "new"
private val newHeader = "New giter8 template."
val newMessage: String = HelpMessages.shortHelpMessage(cmdName, newHeader)

val detailedNewMessage: String =
s"""$newHeader
|
| Creates a new project from a giter8 template.
|
|""".stripMargin
}
1 change: 1 addition & 0 deletions project/deps.sc
Expand Up @@ -113,6 +113,7 @@ object Deps {
// TODO bump once 0.15.5 is out
def expecty = ivy"com.eed3si9n.expecty::expecty:0.16.0"
def fansi = ivy"com.lihaoyi::fansi:0.4.0"
def giter8 = ivy"org.foundweekends.giter8:giter8_2.13:0.16.2"
zetashift marked this conversation as resolved.
Show resolved Hide resolved
def guava = ivy"com.google.guava:guava:32.0.0-jre"
def javaClassName = ivy"io.github.alexarchambault.scala-cli:java-class-name_3:0.1.0"
def jgit = ivy"org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r"
Expand Down