Created
July 18, 2012 08:52
-
-
Save gseitz/3135121 to your computer and use it in GitHub Desktop.
SBT command for extracting completions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sbtcomplete | |
import sbt._ | |
import complete.JLineCompletion | |
import Keys._ | |
object SbtComplete { | |
private val CompletionsCommand = "completions" | |
private val CompletionsBrief = ("<arg>", "The string to complete.") | |
private val CompletionsDetailed = "Displays completions for the specified string. The first (possibly empty) line denotes the common prefix of all results." | |
private def completions = Command.single(CompletionsCommand, CompletionsBrief, CompletionsDetailed) { case (s: State, source) => | |
import JLineCompletion._ | |
lazy val completor = parserAsCompletor(s.combinedParser) | |
val (insert, display) = completor(source, 0) | |
val common = commonPrefix(insert) | |
println(common) | |
display.foreach(println) | |
s | |
} | |
lazy val settings = Seq[Setting[_]]( | |
commands += completions | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment