tfunk

WebJar for tfunk

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

tfunk
Last Version

Last Version

3.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

tfunk
WebJar for tfunk
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/shakyshane/tfunk

Download tfunk

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/tfunk/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>tfunk</artifactId>
    <version>3.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/tfunk/
implementation 'org.webjars.npm:tfunk:3.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/tfunk/
implementation ("org.webjars.npm:tfunk:3.1.0")
'org.webjars.npm:tfunk:jar:3.1.0'
<dependency org="org.webjars.npm" name="tfunk" rev="3.1.0">
  <artifact name="tfunk" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='tfunk', version='3.1.0')
)
libraryDependencies += "org.webjars.npm" % "tfunk" % "3.1.0"
[org.webjars.npm/tfunk "3.1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : chalk jar [1.1.1,2)
org.webjars.npm : object-path jar [0.9.0,0.10)

Project Modules

There are no modules declared in this project.

##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

Versions

Version
3.1.0
3.0.1