Skip to content

Commit

Permalink
Add Ammonite getting started instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Lövgren committed May 12, 2017
1 parent b3a1c7f commit e4802e2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ lazy val docs = project
buildInfoKeys := Seq[BuildInfoKey](
organization,
latestVersion in ThisBuild,
crossScalaVersions in ThisBuild,
crossScalaVersions,
BuildInfoKey.map(moduleName in coreJVM) { case (k, v) "core" + k.capitalize -> v },
BuildInfoKey.map(moduleName in enumeratumJVM) { case (k, v) "enumeratum" + k.capitalize -> v },
BuildInfoKey.map(moduleName in refinedJVM) { case (k, v) "refined" + k.capitalize -> v },
Expand Down
22 changes: 22 additions & 0 deletions docs/src/main/tut/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ The only required module is `ciris-core`, the rest are optional library integrat
- The `ciris-refined` module allows loading [refined][refined] refinement types.
- The `ciris-squants` module allows loading [squants][squants] data types.

#### Ammonite
To start an [Ammonite REPL](http://www.lihaoyi.com/Ammonite/#Ammonite-REPL) with Ciris loaded and imported, simply run the following.
```
curl -Ls try.cir.is | sh
```
You will need to have a JDK installed. The [script](https://try.cir.is) will then:
* download and install the latest available version of [coursier](https://github.com/coursier/coursier),
* use coursier to fetch Ammonite and the latest version of Ciris, and
* start a REPL session with Ciris already imported.

If you already have the Ammonite REPL installed, you can use the following commands to load Ciris.
```tut:evaluated
println(
s"""
|import $$ivy.`$organization::$coreModuleName:$latestVersion`, ciris._
|import $$ivy.`$organization::$enumeratumModuleName:$latestVersion`, ciris.enumeratum._
|import $$ivy.`$organization::$refinedModuleName:$latestVersion`, ciris.refined._
|import $$ivy.`$organization::$squantsModuleName:$latestVersion`, ciris.squants._
""".stripMargin.trim
)
```

### Usage Examples
Ciris configuration loading is done in two parts: define what to load, and what to create once everything is loaded.
Let's start simple by defining a configuration and loading only the necessary parts of it from the environment.
Expand Down
22 changes: 20 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ The only required module is `ciris-core`, the rest are optional library integrat
- The `ciris-refined` module allows loading [refined][refined] refinement types.
- The `ciris-squants` module allows loading [squants][squants] data types.

#### Ammonite
To start an [Ammonite REPL](http://www.lihaoyi.com/Ammonite/#Ammonite-REPL) with Ciris loaded and imported, simply run the following.
```
curl -Ls try.cir.is | sh
```
You will need to have a JDK installed. The [script](https://try.cir.is) will then:
* download and install the latest available version of [coursier](https://github.com/coursier/coursier),
* use coursier to fetch Ammonite and the latest version of Ciris, and
* start a REPL session with Ciris already imported.

If you already have the Ammonite REPL installed, you can use the following commands to load Ciris.
```
import $ivy.`is.cir::ciris-core:0.2.0`, ciris._
import $ivy.`is.cir::ciris-enumeratum:0.2.0`, ciris.enumeratum._
import $ivy.`is.cir::ciris-refined:0.2.0`, ciris.refined._
import $ivy.`is.cir::ciris-squants:0.2.0`, ciris.squants._
```

### Usage Examples
Ciris configuration loading is done in two parts: define what to load, and what to create once everything is loaded.
Let's start simple by defining a configuration and loading only the necessary parts of it from the environment.
Expand Down Expand Up @@ -59,10 +77,10 @@ val config: Either[ConfigErrors, Config] =

```scala
show(config)
// res5: String = Left(ConfigErrors(MissingKey(API_KEY,Environment)))
// res6: String = Left(ConfigErrors(MissingKey(API_KEY,Environment)))

show(config.left.map(_.messages))
// res6: String = Left(Vector(Missing environment variable [API_KEY]))
// res7: String = Left(Vector(Missing environment variable [API_KEY]))
```

#### Encoding Validation
Expand Down

0 comments on commit e4802e2

Please sign in to comment.