Print badges to the terminal. Yup, those nifty little thingies we use on readmes, but for CLI apps.
- Easy to use
- Inbuilt themes
This is what it can do:
var failedBadge = Badge(label: 'failed', message: '2', theme: BadgeTheme.red); var successBadge = Badge(label: 'success', message: '2').green(); var skippedBadge = Badge.yellow(label: 'skipped', message: '2'); print( Badge.inline([ failedBadge, skippedBadge, successBadge ]), );
The above would output something similar to the terminal:
Usage is simple, import the package and start creating Badges!
import 'package:cli_badges/cli_badges.dart'; var failedBadge = Badge(label: 'failed', message: '2', theme: BadgeTheme.red); print(failedBadge);
Some more examples:
You could create a donate badge:
var donateBadge = Badge.cyan(label: '❤️ donate', message: 'please?'); print(donateBadge);
You can also only show the label:
var onlyLabel = Badge( label: '❤️ donate', labelColorCode: 169 ); print(onlyLabel);
Example output is a mock, console output will vary slightly from terminal to terminal.
A badge is conformed of a label and a message
<label>:<message>. Each segment can be customized, by changing bg color, text color and style.
Themes are a way to store badge configuration for repeated use.
You can also swap all themes, this means properties from label will be applied to message and vice versa.
- red : Red Message Background
- green : Green Message Background
- blue : Blue Message Background
- yellow : Black Colored Message on yellow Background
- cyan : Black Colored Message on cyan Background
- magenta : Black Colored Message on magenta Background
- success : ('Success') Message on green Background
- failed : ('Failed') Message on red Background
- warning : ('Failed') Message on yellow Background
- info : ('Info') Message on blue Background
This is the list of all available colors:
There are 3 main ways to create a themed badge:
1 - Passing in the theme directly to the Badge constructor:
Badge( label: 'failed', message: '2', theme: BadgeTheme.red, );
2 - Using named constructors:
Badge.red( label: 'failed', message: '2', );
3 - Or by calling the predefined theme methods:
There is a complete example here
Want badges for some other environment or language?
cli-badges is also available in other languages:
Support the project
I tend to open source anything I can, and love to help people that might need help with the project.
However, 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:
- Starring and sharing the project ?
- Reporting bugs ?
- Sending feedback
- Or even coding :P