-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ Generate Badges for your CLI. | |
|
||
## Features | ||
- Make Beautiful Badges in CLI | ||
- Works with all terminals | ||
- Works across all terminals | ||
- Link support (soon) | ||
- Variety of colors to choose from | ||
- Written in TS with Deno | ||
|
@@ -13,13 +13,13 @@ Generate Badges for your CLI. | |
## Usage | ||
|
||
```ts | ||
import { badges } from "https://deno.land/x/[email protected].2/index.ts"; | ||
import { badges } from "https://deno.land/x/[email protected].3/index.ts"; | ||
|
||
console.log(badges('failed', '2', {msgBg: 'red'})) | ||
console.log(badges('failed', '2', {msgBg: "red"})) | ||
|
||
console.log(badges('success', '2', {msgBg: 'green'})) | ||
console.log(badges('success', '2', {msgBg: "green"})) | ||
|
||
console.log(badges('skipped', '2', {msgBg: 'yellow'})) | ||
console.log(badges('skipped', '2', { msgBg: "yellow"})) | ||
``` | ||
|
||
## Output | ||
|
@@ -39,13 +39,13 @@ console.log(badges('skipped', '2', {msgBg: 'yellow'})) | |
```ts | ||
interface BadgeOptions { | ||
msgBg: string; // default is blue | ||
labelBg: string; // default is black | ||
labelBg: string; // default is brightBlack | ||
msgColor: string; // default is white | ||
labelColor: string; // default is white | ||
msgStyle?: string; | ||
labelStyle?: string; | ||
msgWidth?: number; | ||
labelWidth?: number; | ||
msgStyle?: string; // default is null | ||
labelStyle?: string; // default is null | ||
msgWidth?: number; // default is msg length + 2 | ||
labelWidth?: number; //default is label length + 2 | ||
} | ||
``` | ||
|
||
|
@@ -61,7 +61,14 @@ interface BadgeOptions { | |
- `magenta` | ||
- `cyan` | ||
- `white` | ||
- `gray` | ||
- `brightBlack` | ||
- `brightRed` | ||
- `brightBlue` | ||
- `brightGreen` | ||
- `brightYellow` | ||
- `brightMagenta` | ||
- `brightCyan` | ||
- `brightWhite` | ||
|
||
Custom color support coming soon | ||
|
||
|
@@ -75,6 +82,14 @@ Custom color support coming soon | |
- `magenta` | ||
- `cyan` | ||
- `white` | ||
- `brightBlack` | ||
- `brightRed` | ||
- `brightBlue` | ||
- `brightGreen` | ||
- `brightYellow` | ||
- `brightMagenta` | ||
- `brightCyan` | ||
- `brightWhite` | ||
|
||
Custom color support coming soon | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
//const color = require('cli-color'); | ||
///const terminalLink = require('terminal-link'); | ||
|
||
import * as color from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
import * as color from "https://deno.land/[email protected]/fmt/colors.ts"; | ||
|
||
type ColorType = { [x: string]: (str: string) => string }; | ||
|
||
|
@@ -25,6 +22,14 @@ const colorBgTypes: ColorType = { | |
magenta: (str: string) => color.bgMagenta(str), | ||
cyan: (str: string) => color.bgCyan(str), | ||
white: (str: string) => color.bgWhite(str), | ||
brightBlack: (str: string) => color.bgBrightBlack(str), | ||
brightRed: (str: string) => color.bgBrightRed(str), | ||
brightBlue: (str: string) => color.bgBrightBlue(str), | ||
brightGreen: (str: string) => color.bgBrightGreen(str), | ||
brightYellow: (str: string) => color.bgBrightYellow(str), | ||
brightMagenta: (str: string) => color.bgBrightMagenta(str), | ||
brightCyan: (str: string) => color.bgBrightCyan(str), | ||
brightWhite: (str: string) => color.bgBrightWhite(str), | ||
}; | ||
|
||
const colorTypes: ColorType = { | ||
|
@@ -36,7 +41,14 @@ const colorTypes: ColorType = { | |
magenta: (str: string) => color.magenta(str), | ||
cyan: (str: string) => color.cyan(str), | ||
white: (str: string) => color.white(str), | ||
gray: (str: string) => color.gray(str), | ||
brightBlack: (str: string) => color.brightBlack(str), | ||
brightRed: (str: string) => color.brightRed(str), | ||
brightBlue: (str: string) => color.brightBlue(str), | ||
brightGreen: (str: string) => color.brightGreen(str), | ||
brightYellow: (str: string) => color.brightYellow(str), | ||
brightMagenta: (str: string) => color.brightMagenta(str), | ||
brightCyan: (str: string) => color.brightCyan(str), | ||
brightWhite: (str: string) => color.brightWhite(str), | ||
}; | ||
|
||
const formatters: ColorType = { | ||
|
@@ -61,7 +73,7 @@ function getBgColor( | |
colr: string | undefined, | ||
): (str: string) => string { | ||
if (!colr) { | ||
return color.bgBlue; | ||
return color.bgBrightBlack; | ||
} | ||
return colorBgTypes[colr]; | ||
} | ||
|
@@ -70,7 +82,7 @@ function getTextColor( | |
colr: string | undefined, | ||
): (str: string) => string { | ||
if (!colr) { | ||
return color.bgBlue; | ||
return color.blue; | ||
} | ||
return colorTypes[colr]; | ||
} | ||
|
@@ -90,7 +102,7 @@ function format( | |
|
||
export const DEFAULT_OPTIONS: BadgeOptions = { | ||
msgBg: "blue", | ||
labelBg: "black", | ||
labelBg: "brightBlack", | ||
msgColor: "white", | ||
labelColor: "white", | ||
}; | ||
|