UNPKG

1.9 kBMarkdownView Raw
1
2
3- [CoffeeNode Terminal (TRM)](#coffeenode-terminal-trm)
4 - [Installation & Usage](#installation-&-usage)
5 - [tl;dr](#tl;dr)
6
7> **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
8
9
10# CoffeeNode Terminal (TRM)
11
12## Installation & Usage
13
14On the command line:
15
16 npm install coffeenode-trm
17
18In your scripts:
19
20```coffeescript
21TRM = require 'coffeenode-trm'
22rpr = TRM.rpr.bind TRM
23echo = TRM.echo.bind TRM
24badge = 'any ID text you like'
25log = TRM.get_logger 'plain', badge
26info = TRM.get_logger 'info', badge
27alert = TRM.get_logger 'alert', badge
28debug = TRM.get_logger 'debug', badge
29warn = TRM.get_logger 'warn', badge
30help = TRM.get_logger 'help', badge
31
32info "colors!"
33alert "something went wrong"
34TRM.dir ( new Date() )
35
36# goes to stderr:
37log TRM.gold [ 1, 2, 3, ]
38
39# goes to stdout:
40echo 'redirect only this part with `>`'
41
42# `TRM.pen` (think of 'to pen a text') is like `TRM.echo`, except it does not output anything
43# but returns a textual representation of its arguments:
44message = TRM.pen 'do you like', ( TRM.green 'colorful' ), ( TRM.pink 'outputs' ), '?'
45log message
46
47# `rpr` (short for: 'represenation') gives you a `( require 'util' ).inspect`-like output; it is applied
48# by all `TRM` logging functions by default to avoid any `[object Object]` nonsense; apply it explicitly
49# to get a view into strings.
50log rpr 242 # same as `log 242` (true for all values except texts)
51
52# output: demo ▶ 'do you like \u001b[38;05;34mcolorful\u001b[0m \u001b[38;05;199moutputs\u001b[0m ?\n'
53log rpr message
54
55# convert colors in the message to HTML spans.
56# output: demo ▶ do you like <span class='ansi-m-38-5-34'>colorful</span> <span class='ansi-m-38-5-199'>outputs</span> ?
57log TRM.as_html message
58
59```
60
61## tl;dr
62
63TRM is a library to do simplify doing colorful stuff and meaningful outputs on the command line.
64