Merge pull request #4237 from eed3si9n/wip/help-sbt-new

Fixes `sbt help new` not working as batch command
This commit is contained in:
eugene yokota 2018-06-28 02:10:48 -04:00 committed by GitHub
commit 0dfab79d8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 9 deletions

View File

@ -43,8 +43,14 @@ $HelpCommand <regular expression>
def CompletionsBrief = (CompletionsCommand, CompletionsDetailed)
def templateBrief = (TemplateCommand, "Creates a new sbt build.")
def templateDetailed = TemplateCommand + """ [--options] <template>
Create a new sbt build based on the given template."""
def templateDetailed =
TemplateCommand + """ [--options] <template>
Create a new sbt build based on the given template.
sbt provides out-of-the-box support for Giter8 templates. See foundweekends.org/giter8/ for details.
Example:
sbt new scala/scala-seed.g8
"""
def HistoryHelpBrief =
(HistoryCommands.Start -> "History command help. Lists and describes all history commands.")

View File

@ -116,10 +116,20 @@ object BasicCommands {
}
def runHelp(s: State, h: Help)(arg: Option[String]): State = {
val message = try Help.message(h, arg)
val (extraArgs, remainingCommands) = s.remainingCommands match {
case xs :+ exec if exec.commandLine == "shell" => (xs, exec :: Nil)
case xs => (xs, Nil)
}
val topic = (arg.toList ++ extraArgs.map(_.commandLine)) match {
case Nil => None
case xs => Some(xs.mkString(" "))
}
val message = try Help.message(h, topic)
catch { case NonFatal(ex) => ex.toString }
System.out.println(message)
s
s.copy(remainingCommands = remainingCommands)
}
def completionsCommand: Command =

View File

@ -0,0 +1,13 @@
[@panaeon]: https://github.com/panaeon
[#2932]: https://github.com/sbt/sbt/issues/2939
### Bug fixes
- Make sure that when `sbt help <command>` is executed from the command line it behaves similar to `sbt "help <command>"`.
- Add basic example and link to gitter8 templates page to `sbt new` help message.
### Note:
Unfortunately `sbt help shell` will print default general help message and drop to the sbt shell instead of displaying sbt shell help.
Also now `help` command will consume commands after it so `;help smth; other cmd` will not work.

View File

@ -1,3 +1,3 @@
# Issue 732: reload followed by a command that results in an error exits in interactive mode
-> ;reload;not-a-command
> help
> about

View File

@ -1,2 +1,2 @@
# just need to verify it loads
> help
> about

View File

@ -1,4 +1,4 @@
> help
> about
$ copy-file changes/build.properties project/build.properties
> reload
> checkSbtVersionWarning

View File

@ -9,5 +9,5 @@ $ delete bad.sbt
# due to the previous reload failing, this will force the project to be reloaded first
# and this should then succeed
> help
> about

View File

@ -1,2 +1,2 @@
# just need to verify it loads
> help
> about