搜尋套件、儲存庫與 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! ❤️

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。