Skip to content

scalajs-io/chalk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chalk API for Scala.js

chalk - Terminal string styling done right. Much color.

Description

colors.js 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

Build/publish the SDK locally

 $ sbt clean publish-local

Running the tests

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

$ npm install

Then you can run the tests:

$ sbt test

Examples

import io.scalajs.npm.chalk._

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

Hello World!

import io.scalajs.npm.chalk._

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

Hello World!

import io.scalajs.npm.chalk._

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

Hello World! Foo bar biz baz

import io.scalajs.npm.chalk._

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

Hello World!

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:

libraryDependencies  = "io.scalajs.npm" %%% "chalk" % "0.5.0"

Optionally, you may add the Sonatype Repository resolver:

resolvers  = Resolver.sonatypeRepo("releases") 

Releases

No releases published

Packages

No packages published

Languages