Created
July 8, 2014 08:33
-
-
Save huntc/e4f89679303e89d7a356 to your computer and use it in GitHub Desktop.
Sample command
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 com.typesafe.sbt.rr | |
import sbt._ | |
import Keys._ | |
import complete.DefaultParsers._ | |
import com.typesafe.sbt.SbtNativePackager._ | |
import NativePackagerKeys._ | |
import sbt.complete.Parser | |
object Import { | |
object ReactiveRuntimeKeys { | |
val watchdog = SettingKey[URI]("rr-watchdog", "The location of the watchdog. Defaults to 'http://127.0.0.1:9005'.") | |
} | |
} | |
object SbtReactiveRuntime extends AutoPlugin { | |
val autoImport = Import | |
import autoImport._ | |
import ReactiveRuntimeKeys._ | |
override def projectSettings: Seq[Setting[_]] = Seq( | |
commands += load, | |
watchdog := new URI("http://127.0.0.1:9005") | |
) | |
private def getLatestBundles(state: State): Set[URI] = { | |
val maybeResult: Option[(State, Result[sbt.File])] = Project.runTask(dist in ReactiveRuntime, state) | |
maybeResult match { | |
case None => Set.empty | |
case Some((s, Inc(inc))) => | |
Incomplete.show(inc.tpe) | |
Set.empty | |
case Some((s, Value(f: File))) => Set(f.toURI) | |
} | |
} | |
private def bundle(state: State): Parser[URI] = Space ~> Uri(getLatestBundles(state)) | |
// FIXME: How does the help command work? | |
private def load = Command("load", Help(("load", "<bundle>"), Map("bundle" -> "A URI pointing to the bundle to load")))(bundle) { | |
(state, bundle) => | |
println("Hi " + bundle) | |
state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment