搜索插件、代码仓与 APP 分类

GitHub 代码仓nombrekeff/cli_badges_dart

cli_badges_dart

用于为命令行应用程序生成徽章的奇特小 Dart 库。

cli_badges_dart 项目封面
星标
8
复刻
1
最近推送(UTC)
2022年6月10日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

Quirky little dart library for generating badges for your cli apps.

Pub Version


Print badges to the terminal. Yup, those nifty little thingies we use on readmes, but for CLI apps.

Features

  • Easy to use
  • Inbuilt themes
  • Customizable

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

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.

Badge Structure

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

Themes are a way to store badge configuration for repeated use.

blue theme-blue cyan theme-cyan
green theme-green magenta theme-magenta
red theme-red yellow theme-yellow

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:
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:
Badge(...).red();

Additional info

There is a complete example here

If you encounter any problems or fancy a feature to be added please head over to the GitHub repository and drop an issue.

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

Thanks! ❤️

Manolo Edge GitHub avatar
GitHub 作者

Manolo Edge ↗

Castellón, Spain官方网站 ↗
语言Dart

此仓库发布的插件

使用的依赖

依赖清单 2 项

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗