MCPcopy Index your code
hub / github.com/SergioBenitez/yansi

github.com/SergioBenitez/yansi @v1.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.1 ↗ · + Follow
99 symbols 155 edges 13 files 20 documented · 20%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

yansi logo  Yansi

A dead simple ANSI terminal color painting library.

Build Status Current Crates.io Version Documentation

Usage

In your Cargo.toml:

[dependencies]
yansi = "1.0"

In your source code:

use yansi::Paint;

println!("Testing, {}, {}, {}!",
    "Ready".bold(),
    "Set".black().on_yellow().invert().italic(),
    "STOP".white().on_red().bright().underline().bold());

> Testing, Ready, Set, STOP!

See the rustdocs for complete usage details.

Features

Why yet another ANSI terminal coloring library? Here are some reasons:

  • This library makes simple things simple: use [Paint] and go!
  • Zero dependencies by default. It really is simple.
  • Zero allocations except as needed by opt-in wrapping.
  • Automatic Windows support for the vast majority (95%+) of Windows users.
  • [Featureful no_std], no-alloc, support with default-features = false.
  • [Style constructors are const]: store styles statically, even with dynamic conditions!
  • Any type implementing a formatting trait can be styled, not just strings.
  • Styling can be enabled and disabled globally and dynamically, on the fly.
  • A Style can be predicated on arbitrary conditions.
  • Formatting specifiers like {:x} and {:08b} are supported and preserved!
  • Built-in (optional) conditions for TTY detection and common environment variables.
  • Arbitrary items can be masked for selective disabling.
  • Styling can wrap to preserve styling across resets.
  • Styling can linger beyond a single value.
  • Experimental support for hyperlinking is included.
  • The name yansi is pretty cool 😎.

License

yansi is licensed under either of the following, at your option:

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)

Extension points exported contracts — how you extend this code

Paint (Interface)
A trait to apply styling to any value. Implemented for all types. Because this trait is implemented for all types, you [1 …
src/paint.rs
HyperlinkExt (Interface)
Extension trait to apply hyperlinks to any value, implemented for all types. See the [module level docs](hyperlink) for [1 …
src/hyperlink.rs
SetMember (Interface)
(no doc)
src/set.rs

Core symbols most depended-on inside this repo

contains
called by 13
src/set.rs
write_str
called by 6
src/style.rs
fmt_prefix
called by 4
src/style.rs
store
called by 4
src/condition.rs
splice
called by 3
src/style.rs
color_fmt_value
called by 3
src/paint.rs
fmt
called by 3
src/color.rs
fmt_suffix
called by 2
src/style.rs

Shape

Method 62
Function 18
Class 10
Enum 6
Interface 3

Languages

Rust100%

Modules by API surface

src/style.rs16 symbols
src/condition.rs16 symbols
src/paint.rs14 symbols
src/set.rs13 symbols
src/color.rs10 symbols
tests/basic.rs8 symbols
src/windows.rs6 symbols
src/hyperlink.rs5 symbols
src/attr_quirk.rs5 symbols
src/global.rs4 symbols
src/bitops.rs2 symbols

For agents

$ claude mcp add yansi \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page