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

插件详情v0.0.2

cli_badges

将徽章打印到终端。是的,就是我们在 README 中使用的那些小巧实用的东西,但现在用于 CLI 应用程序。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
3.8万
喜欢数
10
Pub 分数
130

安装插件

flutter pub add cli_badges

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Dart 包,可让 CLI 应用程序在终端中直接打印出色彩丰富、风格时尚的徽章——类似于 README 文件中看到的徽章。它非常适合通过状态、版本或构建信息等视觉指示器来增强命令行输出。该包支持多种平台,并可无缝集成到 Flutter 和 Dart CLI 工具中。只需简单设置,开发者即可为控制台日志添加专业外观的徽章,从而提升终端工作流中的可读性和用户体验。

适合场景

  • 通过视觉状态指示器增强CLI输出
  • 在终端中显示版本和构建信息
  • 提高开发者工具中日志的可读性
  • 向命令行应用程序添加品牌徽章
  • 创建交互式 CLI 仪表板

主要特点

  • 终端徽章渲染
  • 跨平台支持
  • 用于徽章创建的简单 API
  • 色彩丰富且可自定义的徽章
  • 轻量且易于集成

适合对象

  • CLI 工具开发者
  • DevOps 和自动化脚本
  • Flutter CLI 扩展
  • 开发者体验 (DX) 改进
  • 命令行应用程序维护者

使用建议

  • 仅限终端输出
  • 不支持非文本环境
  • 依赖终端颜色功能
  • 在所有终端类型中可能无法一致地呈现
  • 最适合现代的、支持 ANSI 的终端

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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! ❤️

所属分类

源码仓库

使用此插件的项目

暂无相关数据。