{"id":20507236,"url":"https://github.com/nombrekeff/cli-badges","last_synced_at":"2025-04-13T21:32:43.689Z","repository":{"id":48982988,"uuid":"289456693","full_name":"nombrekeff/cli-badges","owner":"nombrekeff","description":"Quirky little node-js library for generating badges for your cli apps.","archived":false,"fork":false,"pushed_at":"2021-09-30T10:16:02.000Z","size":210,"stargazers_count":45,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T11:50:31.102Z","etag":null,"topics":["badges","cli","cli-apps","cli-badges","generating-badges","italic","label","terminal"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nombrekeff.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-22T09:14:40.000Z","updated_at":"2023-06-04T13:01:00.000Z","dependencies_parsed_at":"2022-09-01T13:52:37.054Z","dependency_job_id":null,"html_url":"https://github.com/nombrekeff/cli-badges","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nombrekeff%2Fcli-badges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nombrekeff%2Fcli-badges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nombrekeff%2Fcli-badges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nombrekeff%2Fcli-badges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nombrekeff","download_url":"https://codeload.github.com/nombrekeff/cli-badges/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248786659,"owners_count":21161475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["badges","cli","cli-apps","cli-badges","generating-badges","italic","label","terminal"],"created_at":"2024-11-15T20:03:58.485Z","updated_at":"2025-04-13T21:32:43.649Z","avatar_url":"https://github.com/nombrekeff.png","language":"JavaScript","funding_links":["https://ko-fi.com/logginjs'"],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \n  ![](https://vectr.com/kerff/ddbmvyZmm.svg?width=600\u0026height=300\u0026select=aNbKxciPh)\n  \n  Quirky little node-js library for generating badges for your cli apps.\n  \n  ![GitHub file size in bytes](https://img.shields.io/github/size/nombrekeff/cli-badges/index.js?style=flat-square)\n  [![npm](https://img.shields.io/npm/v/cli-badges?label=version\u0026style=flat-square)](https://www.npmjs.com/package/cli-badges)\n  \n\u003c/div\u003e\n\n---\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [Getting Started](#getting-started)\n  - [Installing](#installing)\n  - [Usage](#usage)\n- [Available Options](#available-options)\n- [Colors](#colors)\n- [Styles](#styles)\n- [Links](#links)\n- [Themes](#themes)\n- [Other Libraries?](#other-libraries)\n\n---\n\n## Getting Started\n\n### Installing\n\nAs usual, you need to install from npm/yarn:\n\n```\n$ npm install cli-badges\n```\n\n### Usage\n\nThis is a simple example, using badges to display test results:\n\n```js\nconst { badge } = require('cli-badges');\n\nconst failedBadge  = badge('failed', '2', { theme: 'red' });\nconst skippedBadge = badge.yellow('skipped', '2');\nconst successBadge = badge.green('success', '2');\n\nconsole.log(failedBadge, successBadge, skippedBadge);\n```\n\nThe above would output something similar to the terminal:\n\n![](./images/output-example.png)\n\nYou could also create a donate badge with a link ([if supported](#links)):\n\n```js\nconst donateBadge = badge.blue('❤️ donate', 'ko-fi', {\n  link: 'https://ko-fi.com/logginjs',\n});\n\nconsole.log(donateBadge);\n```\n\n![](./images/donate-output-example.png)\n\nYou can also only show the label:\n\n```js\nconst onlyLabel = badge('❤️ donate', '', { labelColor: 169 });\n\nconsole.log(onlyLabel);\n```\n\n\u003e ###### Example output is a mock, console output will vary slightly from terminal to terminal.\n\n## Badge Structure \u003c!-- omit in toc --\u003e\n\nA badge is conformed of a label and a message `\u003clabel\u003e:\u003cmessage\u003e`. Each segment can be customized, by changing bg color, text color and style.\n\n## API \u003c!-- omit in toc --\u003e\n\n`cli-badges` exports a method called `badge`.\n\n```ts\nexport function badge(\n  label?: string,\n  message?: string,\n  options?: {\n    labelBg?: string | number;\n    messageBg?: string | number;\n    labelColor?: string | number;\n    messageColor?: string | number;\n    labelStyle?: string;\n    messageStyle?: string;\n    labelWidth?: number;\n    messageWidth?: number;\n    link?: string;\n    forceLink?: boolean;\n    theme?: string;\n    swapTheme?: boolean;\n  }\n): string;\n```\n\n## Available Options\n\n| Option         | Description                                                                               | Type             | Default          |\n| :------------- | :---------------------------------------------------------------------------------------- | :--------------- | :--------------- |\n| `messageBg`    | Background [color](#colors) for the label                                                 | string or number | blue             |\n| `labelBg`      | Background [color](#colors) for the message                                               | string or number | blackBright      |\n| `messageColor` | Text [color](#colors) for the message                                                     | string or number | white            |\n| `labelColor`   | Text [color](#colors) for the label                                                       | string or number | white            |\n| `labelWidth`   | Width of the label                                                                        | number           | label length + 2 |\n| `messageWidth` | Width of the message                                                                      | number           | label length + 2 |\n| `labelStyle`   | Style for the label text                                                                  | string           | `null`           |\n| `messageStyle` | Style for the label text                                                                  | string           | `null`           |\n| `link`         | Add a link when a badge is clicked (_only works in some terminals, see [this](#links)_)   | URL              | `null`           |\n| `forceLink`    | Force adding link even if not supported                                                   | boolean          | `false`          |\n| `theme`        | Theme to be used, see [all themes](./docs/themes.md)                                      | string           | `blue`           |\n| `swapTheme`    | Swap the theme, this means properties from label will be aplied to message and vice versa | boolean          | `false`          |\n\n## Colors\n\n`cli-badges` uses [`cli-color`](https://github.com/medikoo/cli-color#colors) internally for managing colors, you can check the list of available colors there. Take into account that when setting a color you don't need to pass the prefix `bg`, it's handled for you. ie: `blackBright` instead of `bgBlackBright`\n\n#### Xterm colors \u003c!-- omit in toc --\u003e\n\nThere are more colors available using xterm colors, see [cli-color xterm colors](https://github.com/medikoo/cli-color#xterm-colors-256-colors-table) for the complete list of available colors.\n\n\u003e **Not supported on Windows and some terminals.** However if used in not supported environment, the closest color from basic (16 colors) palette is chosen.\n\n## Styles\n\n**cli-badges** uses [`cli-color`](https://github.com/medikoo/cli-color#styles) internally for managing styles, you can check the list of available styles there.\n\n\u003e Styles will display correctly if font used in your console supports them.\n\n## Links\n\nYou can output badges with a link attached to it, that can be clicked in some terminals.\n\n\u003e #### ⚠︎ cli-badges will only output link if its supported by your terminal.\n\n\u003e See [this](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) for information on supported terminals\n\n```js\nbadge('with', 'link', { link: 'https://link.com' });\n```\n\n## Themes\n\n![](./images/themes-preview.png)\n\nThemes are a way to store badge configuration for repeated use. All the options (_except for the theme option, obviously_) that are needed by the badge can be stored by making a theme.\n\nThe library comes with a set of inbuilt themes:\n\n#### Inbuilt Themes \u003c!-- omit in toc --\u003e\n\n- **red** : Red Message Background\n- **green** : Green Message Background\n- **blue** : Blue Message Background\n- **yellow** : Black Colored Message on Yellow Background\n- **cyan** : Black Colored Message on Cyan Background\n- **magenta** : Black Colored Message on Magenta Background\n- **success** : (_'Success'_) Message on Green Background\n- **failed** : (_'Failed'_) Message on Red Background\n\n#### Using Themes \u003c!-- omit in toc --\u003e\n\nYou can use the themes in various ways, passing an option `theme` to badge:\n\n```js\nbadge('label', 'green', { theme: 'green' });\nbadge('label', 'magenta', { theme: 'magenta', swapTheme: true });\n```\n\nOr there are helper methods for ease of use:\n\n```js\nbadge.green('label', 'green');\nbadge.failed('theme', 'red');\n```\n\nOptions present in the theme will override options passed. Missing options will have default values.\n\n### Adding a theme \u003c!-- omit in toc --\u003e\n\nYou can also add you own themes:\n\n```js\nbadge.addTheme('donate', {\n  label: '❤️ donate',\n});\n\nbadge('', 'ko-fi', { theme: 'donate' });\nbadge.donate('', 'ko-fi');\n```\n\n![](./images/donate.png)\n\n\u003e You can also send in a PR and suggest a new inbuilt theme :)\n\n### Swap Properties \u003c!-- omit in toc --\u003e\n\nYou can also **swap** all themes, this means properties from label will be aplied to message and vice versa.\n\n```js\nbadge.failed('theme', 'red');\nbadge.failed.swap('theme', 'red');\n```\n\n![](./images/swap-example.png)\n\nYou can check the complete list of themes [here](./docs/themes.md).\n\n## Want badges for some other environment or language?\n\n**cli-badges** is also available in other languages:\n\n- `Python` [@haideralipunjabi/cli-badges](https://github.com/haideralipunjabi/cli-badges)\n- `Deno` [@Delta456/cli_badges](https://github.com/Delta456/cli_badges)\n- `Dart` [@nombrekeff/cli_badges_dart](https://github.com/nombrekeff/cli_badges_dart)\n\n## Test Coverage \u003c!-- omit in toc --\u003e\n\n| Statements                                                                  | Branches                                                                  | Functions                                                                  | Lines                                                                  |\n| --------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------- |\n| ![Statements](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Branches](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Functions](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) |\n\n## Support the project \u003c!-- omit in toc --\u003e\n\nI tend to open source anything I can, and love to help people that need help with the project.\n\nHowever, if you are using this project and are happy with it or just want to encourage me to continue creating stuff, there are few ways you can do so:\n\n- Starring and sharing the project 🚀\n- Reporting bugs 🐛\n- Sending feedback\n- Or even coding :P\n\nThanks! ❤️\n\n---\n\nContributions are very welcomed 🥰\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnombrekeff%2Fcli-badges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnombrekeff%2Fcli-badges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnombrekeff%2Fcli-badges/lists"}