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.
- Host: GitHub
- URL: https://github.com/scalajs-io/chalk
- Owner: scalajs-io
- License: apache-2.0
- Created: 2017-02-09T10:36:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-17T23:07:36.000Z (about 6 years ago)
- Last Synced: 2025-03-11T07:52:36.207Z (4 months ago)
- Topics: chalk, node, nodejs, npm, npm-package, scala, scalajs
- Language: Scala
- Size: 15.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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")
```