Giter VIP home page Giter VIP logo

tfunk's Introduction

##tfunk Build Status

Multi-colour console output from Chalk with added awesome.

by @shakyshane & @AydinHassan

tfunk

##Install

npm install tfunk

##Usage

Syntax rules:

{ <color> : YOUR STRING }

Example

{blue:This is a blue line}

} is optional

{blue:This is a blue line <- Perfectly valid

##Usage

var tFunk = require("tfunk");

console.log( tfunk("{cyan:tFunk terminal colours") )

// => tFunk terminal colours

Or get a custom compiler with a set prefix:

var compiler = require("tfunk").Compiler({
    prefix: "[{magenta:tFunk}]"
});

console.log( compiler.compile("tFunk is awesome") );
console.log( compiler.compile("don't you think?") );

// => [tFunk] tFunk is awesome
// => [tFunk] don't you think?

Define your own syntax

You can define your own methods, they receive the string section as the first parameter & have access to the compiler through this.compile() keyword.

var compiler = require("tfunk").Compiler({
    "warn": function(string) {
        return this.compile("{red:WARNING:" + string);
    }
});

Now you can use warn anywhere you like.

console.log( compiler.compile("{warn: Could not file your config file...") );

// => WARNING: Could not file your config file...

##Examples

Here are some comparisons to chalk, to help you understand how to use tFunk.

###Single Colours

// chalk
console.log( chalk.red("This has a single colour") );

// tFunk
console.log( tFunk("{red:This has a single colour") );

###Single Colour mid string

// chalk
console.log( "This has a single colour " + chalk.cyan("that begins mid-string") );

// tFunck
console.log( tFunk("This has a single colour {cyan:that begins mid-string") );

###Single Colour with end point

// chalk
console.log( chalk.red("This has a single colour with ") + "an endpoint");

// tFunk
console.log( tFunk("{red:This has a single colour with }an endpoint") );

###Two Colours

// chalk
console.log( chalk.green("This has ") + chalk.cyan("two colours") );

// tFunk
console.log( tFunk("{green:This has {cyan:two colours") );

###Nested Colours

// chalk
console.log( chalk.green("This has a colour " + chalk.cyan("nested inside") + " another colour") );

//tFunk
console.log( tFunk("{green:This has a colour {cyan:nested inside} another colour") );

###Multiple Nested

// chalk
console.log( chalk.blue("Multiple " + chalk.cyan("NESTED") + " styles in " + chalk.red("the same string") + " with an ending") );

// tFunk
console.log( tFunk("{blue:Multiple {cyan:NESTED} styles in {red:the same string} with an ending") );

###Multi line

var multiline = require("multiline");

var string = multiline(function () {/*
{cyan:This is a multi-line coloured string
With a single {yellow:yellow} word in the center of a line
Pretty cool huh?
*/});

console.log( tFunk(string) );

###Escaping when you need curly braces

console.log( tFunk("This has a \\{\\{mustache\\}\\}") );

##TODO

  • Colours
  • Nested Colours
  • Custom syntax
  • Prefixed compiler
  • Make the chain-able API work like this "{white.bgRed: White text, red BG"
  • Offer a way of escaping. Right now, ALL instances of } will be lost

tfunk's People

Contributors

shakyshane avatar aydinhassan avatar shinnn avatar

Stargazers

Glauber Mota avatar Matt Hagner avatar Vincenzo Ferrari avatar Franco Rondini avatar Gustavo Gard avatar Bradley Xu avatar Adrian Carballo avatar Rikki Schulte avatar Lance He avatar Aleksandar Goševski avatar Joshua Appelman avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jbnicolai

tfunk's Issues

Bump npm Dependency `object-path`

Hello shakyShane and tfunk,

npm audit is reporting that the npm package object-path, a dependency of tfunk, is affected by a security vulnerability: https://www.npmjs.com/advisories/1573.

I noticed it because tfunk is in the dependency graph of BrowserSync. I've never really reported on an issue like this, so let me know how to proceed.

Thanks for all of your efforts in the open-source community.

TS

Use better syntax

{ <color> : STRING } is way nicer

console.log( tfunk( "{red: This has a {blue: blue sentence the middle of it} colour") );

Update chalk dependency

At the moment "chalk": "^0.5.1" is being targeted.
Please update this dependency to "1.0" or higher, because these versions contain different improvements https://github.com/chalk/chalk/releases/tag/v1.0.0. One of them is a possibility to force enable color support for processes launched without tty (for example Node.js apps launched from IDE).

Logger method was removed but is still in the tests?

It seems that two commits ago the logger method was removed but is still in the tests. I re-added it to index.js and published a module using this module, but forgot about the missing method and now it doesn't work. Should I submit a PR or did you plan on moving it to somewhere?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.