mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-20 16:14:57 +08:00
Merge pull request #3234 from ChaosinaCan/master
Add cli-color definitions
This commit is contained in:
55
cli-color/cli-color-tests.ts
Normal file
55
cli-color/cli-color-tests.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/// <reference path="cli-color.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
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();
|
||||
96
cli-color/cli-color.d.ts
vendored
Normal file
96
cli-color/cli-color.d.ts
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
// Type definitions for cli-color 0.3.2
|
||||
// Project: https://github.com/medikoo/cli-color
|
||||
// Definitions by: Joel Spadin <https://github.com/ChaosinaCan>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user