Skip to content

Commit

Permalink
release 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Aug 29, 2020
1 parent 8976173 commit b9eb0cb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
```

Expand All @@ -61,7 +61,14 @@ interface BadgeOptions {
- `magenta`
- `cyan`
- `white`
- `gray`
- `brightBlack`
- `brightRed`
- `brightBlue`
- `brightGreen`
- `brightYellow`
- `brightMagenta`
- `brightCyan`
- `brightWhite`

Custom color support coming soon

Expand All @@ -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

Expand Down
28 changes: 20 additions & 8 deletions index.ts
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 };

Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -61,7 +73,7 @@ function getBgColor(
colr: string | undefined,
): (str: string) => string {
if (!colr) {
return color.bgBlue;
return color.bgBrightBlack;
}
return colorBgTypes[colr];
}
Expand All @@ -70,7 +82,7 @@ function getTextColor(
colr: string | undefined,
): (str: string) => string {
if (!colr) {
return color.bgBlue;
return color.blue;
}
return colorTypes[colr];
}
Expand All @@ -90,7 +102,7 @@ function format(

export const DEFAULT_OPTIONS: BadgeOptions = {
msgBg: "blue",
labelBg: "black",
labelBg: "brightBlack",
msgColor: "white",
labelColor: "white",
};
Expand Down

0 comments on commit b9eb0cb

Please sign in to comment.