Skip to content

scalajs-io/colors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Colors API for Scala.js

colors - get colors in your node.js console.

Description

get color and style in your node.js console

Build Requirements

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.nodejs.console
import io.scalajs.npm.colors._
import scala.scalajs.js

console.log(Colors.green("hello"))                        // outputs green text
console.log(Colors.red.underline("i like cake and pies")) // outputs red underlined text
console.log(Colors.inverse("inverse the color"))          // inverses the color
console.log(Colors.rainbow("OMG Rainbows!"))              // rainbow
console.log(Colors.trap("Run the trap"))                  // Drops the bass

console.log("hello".green)                        // outputs green text
console.log("i like cake and pies".underline.red) // outputs red underlined text
console.log("inverse the color".inverse)          // inverses the color
console.log("OMG Rainbows!".rainbow)              // rainbow
console.log("Run the trap".trap)                  // Drops the bass
      
Colors.setTheme(
js.Dictionary(
  "silly"   -> "rainbow",
  "input"   -> "grey",
  "verbose" -> "cyan",
  "prompt"  -> "grey",
  "info"    -> "green",
  "data"    -> "grey",
  "help"    -> "cyan",
  "warn"    -> "yellow",
  "debug"   -> "blue",
  "error"   -> "red"
))

// outputs red text
console.log("this is an error" <<= "error")

// outputs yellow text
console.log("this is a warning" <<= "warn")   

Artifacts and Resolvers

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

libraryDependencies += "io.scalajs.npm" %%% "colors" % "0.5.0"

Optionally, you may add the Sonatype Repository resolver:

resolvers += Resolver.sonatypeRepo("releases") 

Releases

No releases published

Packages

No packages published

Languages