Add color and style to your console output -- the classy
way.
You've styled out your terminal -- bravo, by the way
. While coding, you notice your console output looks underdressed... No style... déclassé
!
You import your favorite colors
library and begin bending over backward with string interpolation, and now your console code is a twisted, spaghetti mess...
You're trying too hard
and that's just not classy
.
npm i cli-classy
If using TypeScript
, use the following import
statements at the top of your .ts
file:
import { Stylesheet, TokenFlags } from 'cli-classy';
// Pull style functions from your preferred color lib
import * as colors from 'ansi-colors';
If using JavaScript
, use the following require
statements at the top of your .js
file:
const { Stylesheet, TokenFlags } = require('cli-classy');
// Pull style functions from your preferred color lib
const colors = require('ansi-colors');
const stylesheet = new Stylesheet()
.addStyle(TokenFlags.Braced, colors.greenBright)
.addStyle(TokenFlags.Bracketed, colors.blueBright)
.addStyle(TokenFlags.Punctuation, colors.cyan)
.addStyle(TokenFlags.Quoted, colors.bgCyanBright.blue)
.stylize();
const ss = stylesheet; // Alias for shorter code
console.log(ss("The quick [brown] fox jumped over the 'lazy dog', and the {cow} jumped over the moon! Enough said."));
Not yet, but coming soon.
Not yet, but coming soon.