fix sbt help new does not explain how to use sbt new

This commit is contained in:
PanAeon 2017-10-24 19:08:56 +01:00
parent bcd21ba9b6
commit 27a30a933a
3 changed files with 33 additions and 4 deletions

View File

@ -41,8 +41,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

@ -87,10 +87,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.