/dabble

The simplest way to load a Scala library into the REPL.

Primary LanguageScalaMIT LicenseMIT

Build Status 0.4.1

Dabble

Ever wanted to play around with a new Scala library but wished there was an easier way to put it on the classpath of the REPL? Tired of manually copying lengthy file paths to specify the classpath?

Let Dabble handle the details for you. Simply run dabble with the libraries of your choosing, similar to how you would see it on its project page on Github or on maven central. Then sit back while dabble downloads any dependencies you need, adds it to the classpath of a Scala repl and launches you in.

Goals

  1. Easy copy-paste of sbt dependencies onto dabble to get something working quickly.
  2. Use SBT to do the heavy lifting.

Requirements

SBT 1.x, Scala 2.12.x

Example

How can we use dabble to play around with the scalaz-core library in the REPL?

Go to the scalaz github page to see what the latest dependency is:

libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.2.2"

Simply grab the part after the += sign and call dabble:

dabble "org.scalaz" %% "scalaz-core" % "7.2.2"

This results in the following output:

  _____        _     _     _
 |  __ \      | |   | |   | |
 | |  | | __ _| |__ | |__ | | ___
 | |  | |/ _` | '_ \| '_ \| |/ _ \
 | |__| | (_| | |_) | |_) | |  __/
 |_____/ \__,_|_.__/|_.__/|_|\___|

Dabble: 0.0.1-b325
Dabble: Using default sbt template at: /Users/sanj/.dabble/build.sbt
[info] Loading global plugins from /Users/sanj/.sbt/0.13/plugins
[info] Set current project to Willow (in build file:/Users/sanj/.dabble/work/)
[info] Starting scala interpreter...
[info]

Dabble injected the following libraries:
[1] org.scalaz %% scalaz-core % 7.2.2

Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_65).
Type in expressions to have them evaluated.
Type :help for more information.

Now we can use scalaz as per usual:

scala> import scalaz._, syntax.either._
import scalaz._
import syntax.either._

scala> 5.right[String]
res1: scalaz.\/[String,Int] = \/-(5)

scala>

Download

Linux or Macosx

To get a executable on Linux or Macosx run:

curl -L -o dabble https://git.io/fxuNb; chmod +x dabble; ./dabble -h

To get a plain jar file run:

curl -L -o dabble.jar https://git.io/fxuN9; java -jar dabble.jar -h

Windows

Download the dabble.jar file and run:

java -jar dabble.jar -h

Alternatively, also download the dabble.bat file into the same directory and run it via:

dabble.bat -h

Build

Linux or Macosx

Build the dabble executable with:

sbt assembly

Once that completes, you can add dabble to your path and make it executable:

cp target/scala_version/dabble ~/bin/
chmod +x ~/bin/dabble

You can run dabble as:

dabble <dependencies>

Windows

Build dabble.jar with:

sbt -Dplain.jar assembly

Once that completes, you can run dabble as:

java -jar dabble.jar <dependencies>

You can also download the sample dabble.bat file and run it as:

dabble.bat <dependencies>

Install on OSX using with brew

Thanks to edwardsmatt for creating a brew tap for dabble.

First, add this tap to your Brew.

brew tap ssanj/homebrew-dabble

Now you will be able to install the latest dabble release:

brew install dabble

Running

dabble <dependencies> <resolvers> <macro-paradise-version>

With a single dependency:

dabble "org.scalaz" %% "scalaz-core" % "7.2.2"

With a single dependency and config:

dabble "org.scalatest" %% "scalatest" % "2.2.6" % "test"

With multiple dependencies separated by a + sign:

dabble "org.scalaz" %% "scalaz-core" % "7.2.2" + "org.scalatest" %% "scalatest" % "2.2.6" % "test"

With a single resolver specified by -r:

dabble -r "Oncue Bintray Repo @ http://dl.bintray.com/oncue/releases" "oncue.knobs" %% "core" % "3.6.1"

or

dabble "oncue.knobs" %% "core" % "3.6.1" -r "Oncue Bintray Repo @ http://dl.bintray.com/oncue/releases"

Resolvers can be specified before or after the dependencies.

With multiple resolvers separated by a ,:

dabble -r "bintray:bmjames:maven, sonatype" "net.bmjames" %% "scala-optparse-applicative" % "0.3"

or

dabble "net.bmjames" %% "scala-optparse-applicative" % "0.3" -r "bintray:bmjames:maven, sonatype"

With a specific version of the macro paradise compiler plugin:

dabble "com.github.mpilquist" %% "simulacrum" % "0.7.0" -mp "2.1.0"

Configuration

Dabble operates out of the ~/.dabble directory. When you run dabble, a minimal build.sbt file is generated and written to the ~/.dabble/work directory. This is then used to run the build containing all the artefacts. You can override the generated build.sbt by placing your own build.sbt file under ~/.dabble/.

You can also override the sbt version used by specifying a version in the ~/.dabble/work/project/build.properties file.

You can get a full list of arguments to dabble by running it with -h or --help:

Dabble version: 0.4.1-b3371
Usage: Dabble [history] [options] [<dep1> + <dep2> + ... <depn>]

  -h, --help
  -v, --version
  <dep1> + <dep2> + ... <depn>
                           The list of dependencies to include.
  Multiple dependencies should be separated by a + sign.

  Format is one of:
  "org1" %  "name1" % "version1"
  "org2" %% "name2" % "version2"
  "org3" %% "name3" % "version3 % "config""
  "org1" %% "name1" % "version1" + "org2" %% "name2" % "version2"

  Example:
  "com.github.scopt" %% "scopt" % "3.4.0" + "org.scalaz" %% "scalaz-core" % "7.2.2"

  -r, --resolvers "<res1>,<res2>, .... <resn>"
                           The list of additional repositories to resolve dependencies from.
  Multiple dependencies should be separated by commas.

  Format is one of:
  (sonatype|typesafe|typesafeIvy|sbtPlugin):[s|r]
  (maven2|jcenter)
  bintray(owner:repo)
  name@repo_url

  sonatype:s -- loads only snapshot repo
  sonatype:r -- loads only release repo
  sonatype   -- loads both snapshot and release repos
  maven2     -- loads the maven2 resolver
  bintray:user:repo  -- loads the bintray resolver for user/repo
  your repo name @ https://your.repo.com/release/maven -- loads a custom resolver

  Example:
  "bintray:oncue:releases, sonatype:r"

  -mp, --macro-paradise <version>
                           Includes the macro paradise compiler plugin with the supplied version.

  Example:
  2.1.0

Please see https://github.com/ssanj/dabble for more examples.
Command: history [options]
command history.
  -t, --term <search term>
                           The term to search through history for

Releasing

Bump version in build.sbt

Create the Linux/Macos-specific jar:

sbt assembly

Create the plain jar:

sbt -Dplain.jar assembly

This will update build.properties

Commit changes, tag and push:

git cm changes
git tag -a newversion
git push
git push --tags

Create release in Github against tag

Upload the artifacts from the target/scala-version/dabble directory:

  • dabble
  • dabble.jar
  • dabble.bat (download from a previous version and upload)

Update the README.md with the Github link shortener to these downloads:

curl -i https://git.io -F "url=https://github.com/ssanj/dabble/releases/download/version/dabble.jar"

curl -i https://git.io -F "url=https://github.com/ssanj/dabble/releases/download/version/dabble"

Update the README with these new links.

Update version pill

Update the Homebrew tap with the latest version and sha:

shasum -a 256 target/scala-version/dabble

Commit and push the Homebrew tap:

git cm
git push