From 954e7444086e4345c767585574d6cec9a2d83cb3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 22 Aug 2016 02:38:46 -0400 Subject: [PATCH] Adds templateResolvers and `new` command This adds `new` command, which helps create a new build definition. The `new` command is extensible via a mechanism called the template resolver, which evaluates the arbitrary arguments passed to the command to find and run a template. As a reference implementation [Giter8][g8] is provided as follows: sbt new eed3si9n/hello.g8 This will run eed3si9n/hello.g8 using Giter8. [g8]: http://www.foundweekends.org/giter8/ --- build.sbt | 2 +- .../main/scala/sbt/BasicCommandStrings.scala | 5 +++ .../src/main/scala/sbt/BasicCommands.scala | 23 ++++++++++++- .../src/main/scala/sbt/BasicKeys.scala | 2 ++ main/src/main/scala/sbt/Defaults.scala | 1 + .../scala/sbt/Giter8TemplateResolver.scala | 32 +++++++++++++++++++ main/src/main/scala/sbt/Keys.scala | 2 ++ main/src/main/scala/sbt/Main.scala | 2 +- main/src/main/scala/sbt/PluginDiscovery.scala | 3 +- main/src/main/scala/sbt/Project.scala | 8 +++-- .../sbt/plugins/Giter8ResolverPlugin.scala | 17 ++++++++++ notes/0.13.13/template_cmd.md | 14 ++++++++ project/Dependencies.scala | 2 ++ 13 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 main/src/main/scala/sbt/Giter8TemplateResolver.scala create mode 100644 main/src/main/scala/sbt/plugins/Giter8ResolverPlugin.scala create mode 100644 notes/0.13.13/template_cmd.md diff --git a/build.sbt b/build.sbt index 55741a19d..9faf95b91 100644 --- a/build.sbt +++ b/build.sbt @@ -449,7 +449,7 @@ lazy val commandProj = (project in mainPath / "command"). settings( testedBaseSettings, name := "Command", - libraryDependencies += launcherInterface + libraryDependencies ++= Seq(launcherInterface, templateResolverApi, giter8) ) // Fixes scope=Scope for Setting (core defined in collectionProj) to define the settings system used in build definitions diff --git a/main/command/src/main/scala/sbt/BasicCommandStrings.scala b/main/command/src/main/scala/sbt/BasicCommandStrings.scala index 76f79e623..8750e027a 100644 --- a/main/command/src/main/scala/sbt/BasicCommandStrings.scala +++ b/main/command/src/main/scala/sbt/BasicCommandStrings.scala @@ -14,6 +14,7 @@ object BasicCommandStrings { val CompletionsCommand = "completions" val Exit = "exit" val Quit = "quit" + val TemplateCommand = "new" /** The command name to terminate the program.*/ val TerminateAction: String = Exit @@ -35,6 +36,10 @@ object BasicCommandStrings { def CompletionsDetailed = "Displays a list of completions for the given argument string (run 'completions ')." def CompletionsBrief = (CompletionsCommand, CompletionsDetailed) + def templateBrief = (TemplateCommand, "Creates a new sbt build.") + def templateDetailed = TemplateCommand + """ [--options]