DEV Community

Cover image for Badges for the terminal
Keff
Keff

Posted on • Updated on

Badges for the terminal

Hey there!

I've just released a little quirky node-js library. Add badges to your cli apps or npm packages.

GitHub logo nombrekeff / cli-badges

Quirky little node-js library for generating badges for your cli apps.

Quirky little node-js library for generating badges for your cli apps.

GitHub file size in bytes npm


Table Of Contents


Getting Started

Installing

As usual, you need to install from npm/yarn:

$ npm install cli-badges

Usage

This is a simple example, using badges to display test results:

const { badge } = require('cli-badges');

const failedBadge  = badge('failed', '2', { theme: 'red' });
const skippedBadge = badge.yellow('skipped', '2');
const successBadge = badge.green('success', '2');

console.log(failedBadge, successBadge, skippedBadge);
Enter fullscreen mode Exit fullscreen mode

The above would output something similar to the terminal:

You could also create a donate badge with a link (if supported):

const donateBadge = badge.blue('❤️ donate',
Enter fullscreen mode Exit fullscreen mode

Usage

This is a simple example, using badges to display test results:

const { badge } = require('cli-badges');

const failedBadge = badge('failed', '2', { 
  messageBg: 'red' 
});
const skippedBadge = badge('skipped', '2', {
  messageBg: 'yellow',
  messageColor: 'white',
});
const successBadge = badge('success', '2', {
  messageBg: 'green',
  messageColor: 'white',
});

console.log(failedBadge, successBadge, skippedBadge);
Enter fullscreen mode Exit fullscreen mode

The above would output something similar to the terminal:

You could also create a donate badge with a link (if supported):

const { badge } = require('cli-badges');

const donateBadge = badge('donate', 'ko-fi', {
  link: 'https://ko-fi.com/logginjs',
});

console.log(donateBadge);
Enter fullscreen mode Exit fullscreen mode

Example output is a mock, console output will vary slightly from terminal to terminal.

cli-badges is now also available for Python, thanks to haideralipunjabi.

GitHub logo haideralipunjabi / cli-badges

Quirky little python package for generating badges for your cli apps.


It would be awesome if you could pass by and give me some feedback. 🥰

Top comments (8)

Collapse
 
sroehrl profile image
neoan

Cool. It's those nifty little fun things we all love, isn't it?

Collapse
 
nombrekeff profile image
Keff

Yup, not as useful as shields.io, but could have some fun usecases. I'm using it for an experimental testing framework I'm building.

Collapse
 
ahkohd profile image
Victor Aremu

Awesome project!

Collapse
 
nombrekeff profile image
Keff

Thanks man! Just a fun little thingy 😊

Collapse
 
prafulla-codes profile image
Prafulla Raichurkar

This is super cool, I'm going to use it in Express Autodocs

Collapse
 
nombrekeff profile image
Keff

That would be great! 🥰

Collapse
 
nombrekeff profile image
Keff

cli-badges is also available for python now, ported by haideralipunjabi.

github.com/haideralipunjabi/cli-ba...

Collapse
 
nombrekeff profile image
Keff

Made a dart version, and a post for it 😀