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 |
|
14 | On the command line:
|
15 |
|
16 | npm install coffeenode-trm
|
17 |
|
18 | In your scripts:
|
19 |
|
20 | ```coffeescript
|
21 | TRM = require 'coffeenode-trm'
|
22 | rpr = TRM.rpr.bind TRM
|
23 | echo = TRM.echo.bind TRM
|
24 | badge = 'any ID text you like'
|
25 | log = TRM.get_logger 'plain', badge
|
26 | info = TRM.get_logger 'info', badge
|
27 | alert = TRM.get_logger 'alert', badge
|
28 | debug = TRM.get_logger 'debug', badge
|
29 | warn = TRM.get_logger 'warn', badge
|
30 | help = TRM.get_logger 'help', badge
|
31 |
|
32 | info "colors!"
|
33 | alert "something went wrong"
|
34 | TRM.dir ( new Date() )
|
35 |
|
36 | # goes to stderr:
|
37 | log TRM.gold [ 1, 2, 3, ]
|
38 |
|
39 | # goes to stdout:
|
40 | echo '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:
|
44 | message = TRM.pen 'do you like', ( TRM.green 'colorful' ), ( TRM.pink 'outputs' ), '?'
|
45 | log 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.
|
50 | log 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'
|
53 | log 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> ?
|
57 | log TRM.as_html message
|
58 |
|
59 | ```
|
60 |
|
61 | ## tl;dr
|
62 |
|
63 | TRM is a library to do simplify doing colorful stuff and meaningful outputs on the command line.
|
64 |
|