An open API service indexing awesome lists of open source software.

https://github.com/scalajs-io/chalk

Terminal string styling done right. Much color.
https://github.com/scalajs-io/chalk

chalk node nodejs npm npm-package scala scalajs

Last synced: 6 days ago
JSON representation

Terminal string styling done right. Much color.

Awesome Lists containing this project

README

        

Chalk API for Scala.js
================================
[chalk](https://www.npmjs.com/package/chalk) - Terminal string styling done right. Much color.

### Description

[colors.js](https://github.com/scalajs-io/colors) used to be the most popular string styling module, but it has serious deficiencies
like extending String.prototype which causes all kinds of problems. Although there are other ones,
they either do too much or not enough.

**Chalk is a clean and focused alternative.**

### Build Dependencies

* [SBT v1.2.x](http://www.scala-sbt.org/download.html)

### Build/publish the SDK locally

```bash
$ sbt clean publish-local
```

### Running the tests

Before running the tests the first time, you must ensure the npm packages are installed:

```bash
$ npm install
```

Then you can run the tests:

```bash
$ sbt test
```

### Examples

```scala
import io.scalajs.npm.chalk._

// style a string")
println(Chalk.blue("Hello world!"))
```
Hello World!

```scala
import io.scalajs.npm.chalk._

// compose multiple styles using the chainable API
println(Chalk.blue.bgRed.bold("Hello world!"))
```
Hello World!

```scala
import io.scalajs.npm.chalk._

// pass in multiple arguments
println(Chalk.blue("Hello", "World!", "Foo", "bar", "biz", "baz"))
```
Hello World! Foo bar biz baz

```scala
import io.scalajs.npm.chalk._

// nested styles
println(Chalk.red("Hello", Chalk.underline.bgBlue("World") + "!"))
```
Hello World!

```scala
import io.scalajs.nodejs.console
import io.scalajs.npm.chalk._

// use it like a function
val error = Chalk.bold.red
console.log(error("Error!"))
```
Error!

### Artifacts and Resolvers

To add the `Chalk` binding to your project, add the following to your build.sbt:

```sbt
libraryDependencies += "io.scalajs.npm" %%% "chalk" % "0.5.0"
```

Optionally, you may add the Sonatype Repository resolver:

```sbt
resolvers += Resolver.sonatypeRepo("releases")
```