Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nombrekeff/cli_badges_dart
Quirky little dart library for generating badges for cli apps.
https://github.com/nombrekeff/cli_badges_dart
Last synced: about 12 hours ago
JSON representation
Quirky little dart library for generating badges for cli apps.
- Host: GitHub
- URL: https://github.com/nombrekeff/cli_badges_dart
- Owner: nombrekeff
- License: mit
- Created: 2021-09-30T09:13:37.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-10T20:38:34.000Z (over 2 years ago)
- Last Synced: 2023-08-20T21:35:52.445Z (about 1 year ago)
- Language: Dart
- Size: 61.5 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![](https://vectr.com/kerff/ddbmvyZmm.svg?width=600&height=300&select=aNbKxciPh)
Quirky little dart library for generating badges for your cli apps.[![Pub Version](https://img.shields.io/pub/v/cli_badges?style=flat-square)](https://pub.dev/packages/cli_badges)
---
Print badges to the terminal. Yup, those nifty little thingies we use on readmes, but for CLI apps.
## Features
* Easy to use
* Inbuilt themes
* CustomizableThis is what it can do:
```dart
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:
![](https://github.com/nombrekeff/cli_badges_dart/blob/main/images/output-example.png)
## UsageUsage is simple, import the package and start creating Badges!
```dart
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:```dart
var donateBadge = Badge.cyan(label: '❤️ donate', message: 'please?');print(donateBadge);
```![](https://github.com/nombrekeff/cli_badges_dart/blob/main/images/donate-output-example.png)
You can also only show the label:
```dart
var onlyLabel = Badge(
label: '❤️ donate',
labelColorCode: 169
);print(onlyLabel);
```> ###### Example output is a mock, console output will vary slightly from terminal to terminal.
## Badge Structure
A badge is conformed of a **label** and a **message** `:`. Each segment can be customized, by changing bg color, text color and style.
## Themes
Themes are a way to store badge configuration for repeated use.| | | | |
| ------- | ---------------------------------------------------------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------- |
| `blue` | ![theme-blue](https://github.com/nombrekeff/cli_badges_dart/blob/main/images/theme-blue.png) | `cyan` | ![theme-cyan](https://github.com/nombrekeff/cli_badges_dart/blob/main/images/theme-cyan.png) |
| `green` | ![theme-green](https://github.com/nombrekeff/cli_badges_dart/blob/main/images/theme-green.png) | `magenta` | ![theme-magenta](https://github.com/nombrekeff/cli_badges_dart/blob/main/images/theme-magenta.png) |
| `red` | ![theme-red](https://github.com/nombrekeff/cli_badges_dart/blob/main/images/theme-red.png) | `yellow` | ![theme-yellow](https://github.com/nombrekeff/cli_badges_dart/blob/main/images/theme-yellow.png) |You can also **swap** all themes, this means properties from label will be applied to message and vice versa.
### Inbuilt themes
- **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### Colors
This is the list of all available colors:
* red
* black
* green
* yellow
* blue
* magenta
* cyan
* white
* brightRed
* brightBlack
* brightGreen
* brightYellow
* brightBlue
* brightMagenta
* brightCyan
* brightWhite### Using themes
There are 3 main ways to create a themed badge:
#### 1 - Passing in the theme directly to the Badge constructor:
```dart
Badge(
label: 'failed',
message: '2',
theme: BadgeTheme.red,
);
```#### 2 - Using named constructors:
```dart
Badge.red(
label: 'failed',
message: '2',
);
```#### 3 - Or by calling the predefined theme methods:
```dart
Badge(...).red();
```## Additional info
There is a complete example [here](https://github.com/nombrekeff/cli_badges_dart/tree/main/example)
If you encounter any problems or fancy a feature to be added please head over to the GitHub [repository](https://github.com/nombrekeff/cli_badges_dart/) and [drop an issue](https://github.com/nombrekeff/cli_badges_dart/issues/new).
## Want badges for some other environment or language?
**cli-badges** is also available in other languages:
- `JS` [@nombrekeff/cli-badges](https://github.com/nombrekeff/cli-badges)
- `Python` [@haideralipunjabi/cli-badges](https://github.com/haideralipunjabi/cli-badges)
- `Deno` [@Delta456/cli_badges](https://github.com/Delta456/cli_badges)## 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 :PThanks! ❤️