0.0.1 • Published 3 years ago

terminotion v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

Terminotion

Log to console with style.

This package use chalk and a custom syntax to print styled text to the node console.

Table of contents

Installation

npm:

npm install terminotion

yarn:

yarn add terminotion

Usage

With node require:

const tn = require('terminotion');

With Import syntax:

import tn from 'terminotion';

Quick examples:

console.log(tn`?{This is a warning message!}`)

console.log(tn`!{This is a error message!}`)

console.log(tn`:{This is a note message!}`)

console.log(tn`@{This is a success message!}`)

console.log(tn`#480ff5{This is a hexadecimal colored message!}`)

console.log(tn`[226, 15, 245]{This is a rgb colored message!}`)

console.log(tn`This is a **bold** text!`)

Outputs:

Warning example

Styles and Syntax

Styled text is defined as a combination of the characters !?@:[]# with {}.

Error

Syntax: !{text}

Example:

log`This is a !{error message}`

Warning

Syntax: ?{text}

Example:

log`This is a ?{warning message}`

Note

Syntax: :{text}

Example:

log`This is a :{note message}`

Success

Syntax: @{text}

Example:

log`This is a @{success message}`

Hex Color

Syntax: #value{text} where value is the hexadecimal value of the color.

Example:

log`This is a #fc039d{pretty cool pink message}`

RGB Color

Syntax: [r,g,b]{text} where r, g and b are red, green and blue values, respectively.

Example:

log`This is a [36, 252, 3]{very green message}`

Bold

Syntax: **text**

Example:

log`This is a **bold message**`

Italic

Syntax: _text_

Example:

log`This is a _italic message_`

Note that italic may not be supported in all terminals

Custom palette

You can redefine the colors for each style with your owns!

const { palette } = require('terminotion');

const { log } = palette({
   error: '#EC4899',
   sucess: '#A3E635',
   note: '#93C5FD',
   warning: '#FCA5A5'
})

log`!{Error: some error ocurred}`

log`@{Success: successfully done something}`

log`:{Note: something to remember}`

log`?{Warning: something to pay attention}`

Outputs:

Custom palette output

Default palette

The default colors are:

StyleColorValue
Error#EF4444 #EF4444
Warning#EAB308 #EAB308
Note#4F46E5 #4F46E5
Success#10B981 #10B981

Author

This node package is created and maintained by Jorge Brito.

License

This package is under the MIT License.