From 94b15933e91b2ae7492b1483076ea6776f1c611b Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Wed, 26 Nov 2014 21:18:09 -0600 Subject: [PATCH 1/3] Add cli-color definitions Added definitions for cli-color (https://github.com/medikoo/cli-color) --- cli-color/cli-color-tests.ts | 60 ++++++++++++++++++++++++ cli-color/cli-color.d.ts | 91 ++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 cli-color/cli-color-tests.ts create mode 100644 cli-color/cli-color.d.ts diff --git a/cli-color/cli-color-tests.ts b/cli-color/cli-color-tests.ts new file mode 100644 index 0000000000..79dccd7f79 --- /dev/null +++ b/cli-color/cli-color-tests.ts @@ -0,0 +1,60 @@ +// Type definitions for cli-color 0.3.2 +// Project: https://github.com/medikoo/cli-color +// Definitions by: Joel Spadin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +import clc = require('cli-color'); +import ansiTrim = require('cli-color/trim'); +import setupThrobber = require('cli-color/throbber'); + +var text: string; +var color: number; +var x: number; +var y: number; +var n: number; +var period: number; + +// Test cli-color +text = clc('foo'); +text = clc('foo', 42, { toString: () => 'bar' }); + +text = clc.bold.italic.underline.blink.inverse.strike(text); +text = clc.black.red.green.yellow.blue.magenta.cyan.white(text); +text = clc.bgBlack.bgRed.bgGreen.bgYellow.bgBlack.bgMagenta.bgCyan.bgWhite(text); +text = clc.blackBright.redBright.greenBright.yellowBright.blueBright.magentaBright.cyanBright.whiteBright(text); +text = clc.bgBlackBright.bgRedBright.bgGreenBright.bgYellowBright.bgBlueBright.bgMagentaBright.bgCyanBright.bgWhiteBright(text); +text = clc.xterm(color).bgXterm(color)(text); + +text = clc.bold.red.bgGreen.yellowBright.bgBlueBright.xterm(color)(text, text, text); + +text = clc.move(x, y); +text = clc.moveTo(x, y); +text = clc.bol(); +text = clc.bol(n); +text = clc.bol(n, true); +text = clc.up(n); +text = clc.down(n); +text = clc.left(n); +text = clc.right(n); +text = clc.beep; +text = clc.reset; + +var width: number = clc.width; +var height: number = clc.height; +var support: boolean = clc.xtermSupported; + +// Test cli-color/trim +text = ansiTrim(clc.red(text)); + +// Test cli-color/throbber +var throbber: setupThrobber.Throbber; + +throbber = setupThrobber(process.stdout.write.bind(process.stdout), period); +throbber = setupThrobber(process.stdout.write.bind(process.stdout), period, clc.red); + +throbber.start(); +throbber.stop(); +throbber.restart(); diff --git a/cli-color/cli-color.d.ts b/cli-color/cli-color.d.ts new file mode 100644 index 0000000000..903bba914c --- /dev/null +++ b/cli-color/cli-color.d.ts @@ -0,0 +1,91 @@ +declare module "cli-color" { + module m { + export interface Format { + (...text: any[]): string; + + bold: Format; + italic: Format; + underline: Format; + blink: Format; + inverse: Format; + strike: Format; + + black: Format; + red: Format; + green: Format; + yellow: Format; + blue: Format; + magenta: Format; + cyan: Format; + white: Format; + + bgBlack: Format; + bgRed: Format; + bgGreen: Format; + bgYellow: Format; + bgBlue: Format; + bgMagenta: Format; + bgCyan: Format; + bgWhite: Format; + + blackBright: Format; + redBright: Format; + greenBright: Format; + yellowBright: Format; + blueBright: Format; + magentaBright: Format; + cyanBright: Format; + whiteBright: Format; + + bgBlackBright: Format; + bgRedBright: Format; + bgGreenBright: Format; + bgYellowBright: Format; + bgBlueBright: Format; + bgMagentaBright: Format; + bgCyanBright: Format; + bgWhiteBright: Format; + + xterm(color: number): Format; + bgXterm(color: number): Format; + + move(x: number, y: number): string; + moveTo(x: number, y: number): string; + bol(n?: number, erase?: boolean): string; + up(n: number): string; + down(n: number): string; + left(n: number): string; + right(n: number): string; + + beep: string; + reset: string; + + width: number; + height: number; + xtermSupported: boolean; + } + } + + var m: m.Format; + export = m; +} + +declare module "cli-color/trim" { + function ansiTrim(str: string): string; + export = ansiTrim; +} + +declare module "cli-color/throbber" { + import clc = require('cli-color'); + + module setupThrobber { + export interface Throbber { + start(): void; + stop(): void; + restart(): void; + } + } + + function setupThrobber(write: (str: string) => any, period: number, format?: clc.Format): setupThrobber.Throbber; + export = setupThrobber; +} \ No newline at end of file From 4d7acaa55cc1c2964636f3ad841a44a4a5fc9f0d Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Wed, 26 Nov 2014 21:19:38 -0600 Subject: [PATCH 2/3] Newlines! --- cli-color/cli-color.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli-color/cli-color.d.ts b/cli-color/cli-color.d.ts index 903bba914c..41cd17ccec 100644 --- a/cli-color/cli-color.d.ts +++ b/cli-color/cli-color.d.ts @@ -88,4 +88,4 @@ declare module "cli-color/throbber" { function setupThrobber(write: (str: string) => any, period: number, format?: clc.Format): setupThrobber.Throbber; export = setupThrobber; -} \ No newline at end of file +} From be695ebd60d897cdadca661e4f668cf19a251714 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Thu, 27 Nov 2014 19:23:54 -0600 Subject: [PATCH 3/3] Move header to the right file Whoops. --- cli-color/cli-color-tests.ts | 7 +------ cli-color/cli-color.d.ts | 7 ++++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cli-color/cli-color-tests.ts b/cli-color/cli-color-tests.ts index 79dccd7f79..627377b47f 100644 --- a/cli-color/cli-color-tests.ts +++ b/cli-color/cli-color-tests.ts @@ -1,9 +1,4 @@ -// Type definitions for cli-color 0.3.2 -// Project: https://github.com/medikoo/cli-color -// Definitions by: Joel Spadin -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// +/// /// import clc = require('cli-color'); diff --git a/cli-color/cli-color.d.ts b/cli-color/cli-color.d.ts index 41cd17ccec..5764a646c9 100644 --- a/cli-color/cli-color.d.ts +++ b/cli-color/cli-color.d.ts @@ -1,4 +1,9 @@ -declare module "cli-color" { +// Type definitions for cli-color 0.3.2 +// Project: https://github.com/medikoo/cli-color +// Definitions by: Joel Spadin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "cli-color" { module m { export interface Format { (...text: any[]): string;