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

https://github.com/gughog/clr-js

A simple library for Node.js CLI apps to colorize and add some life to bash texts. (WIP)
https://github.com/gughog/clr-js

bash cli clr clr-js color library nodejs opensource

Last synced: about 2 months ago
JSON representation

A simple library for Node.js CLI apps to colorize and add some life to bash texts. (WIP)

Awesome Lists containing this project

README

          

# Clr.js - The dead-simple terminal colors for Node.js.

Clr is a dead simple color library for nodejs to colorize things and put some styles to your strings in your terminal. It's a Work-in-progress (WIP) currently in the 1.0.0 version, yay!

Actually clr-js is just a project for fun, to learn new things and to play with some nice features of the world of development. If you have a better approach to this, please, contribute! Or if you just want to install for create your terminal based apps, feel free to do it.

This is my first open-source contribution, so if you find any errors, bugs or something bad, please report and let's learn together. :smile:

## Getting started

### Installation

* With NPM:
`npm install clr-js`

* With Yarn:
`yarn add clr-js`

---

### Usage (New 1.0.0 version)

This 1.0.0 version introduces the chaining methods for Clr-js! To use in your Javascript/Typescript file:

```js
const clr = require('clr-js');

// A bold and yellow text will be shown in your terminal!
console.log(
clr.bold('Hello, javascript colorful world!')
.yellow()
.it();
)
```

```ts
import * as clr from '../clr';

console.log(
clr.bold('Hello, typescript colorful world!')
.blue()
.it();
)
```

Notice: You only need to declare the string you'll paint in the first method.

Notice2: A little tweak was made for finish the method chaining: when you done calling all your methods, finish the chain with `.it()`.

## API (ver. 1.0.0)

### Colors:

Color | Applying to text | Applying to background
------------|---------------------------|-----------------------
Blue | `clr.blue().it()` | `clr.bblue().it()`
Red | `clr.red().it()` | `clr.bred().it()`
Yellow | `clr.yellow().it()` | `clr.byellow().it()`
Green | `clr.green().it()` | `clr.bgreen().it()`
Cyan | `clr.cyan().it()` | `clr.bcyan().it()`
Magenta | `clr.magenta().it()` | `clr.bmagenta().it()`
White | `clr.white().it()` | `clr.bwhite().it()`
Black | `clr.black().it()` | `clr.bblack().it()`

### Special Text Formatting

Text Formatting | Method
----------------|--------
Bold text | `clr.bold().it()`
Underlined | `clr.uline().it()`
Dark text | `clr.darky().it()`
Stroke | `clr.stroke().it()`

### Applying Special formatting and colors in texts:

```js
const clr = require('clr-js');

let stringy = 'My colorful string.';

// Bold and blue text;
console.log(
clr.bold(stringy)
.blue()
.it();
)

// Bold, underlined magenta-colored text;
console.log(
clr.bold(stringy)
.uline()
.magenta()
.it();
)

// White background with black text;
console.log(
clr.bwhite(stringy)
.black()
.it();
)

// Or just use inline
console.log(
clr.bwhite(stringy).black().it();
)

```

---
---

## The guide bellow refers to the old version of Clr-js, and is not compatible with 1.0.0!

### Usage (ver. 0.1.7 and bellow only)

To use in your Javascript/Typescript file:

```js
const clr = require('clr-js');

// A bold and blue text will be shown in your terminal!
console.log(clr.bold(clr.blue('Hello, colorful world!')))
```

## API

### Colors:

Color | Applying to text | Applying to background
------------|----------------------|-----------------------
Blue | `clr.blue()` | `clr.bblue()`
Red | `clr.red()` | `clr.bred()`
Yellow | `clr.yellow()` | `clr.byellow()`
Green | `clr.green()` | `clr.bgreen()`
Cyan | `clr.cyan()` | `clr.bcyan()`
Magenta | `clr.magenta()` | `clr.bmagenta()`
White | `clr.white()` | `clr.bwhite()`
Black | `clr.black()` | `clr.bblack()`

### Special Text Formatting

Text Formatting | Method
----------------|--------
Bold text | `clr.bold()`
Underlined | `clr.uline()`
Dark text | `clr.darky()`
Stroke | `clr.stroke()`

### Applying Special formatting in colored texts:

```js
let stringy = 'My colorful string.';

console.log( clr.bold(clr.blue(stringy)) ) // Bold and blue text;
console.log( clr.bold(clr.uline(clr.magenta(stringy))) ) // Bold, underlined magenta-colored text;
console.log( clr.bwhite(clr.black(stringy)) ) // White background with black text;
```