console

A Rust library for terminal and console abstraction: colors, styles, cursor control, and terminal size detection

Library
Cargo
v0.16.4
1,191stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
67/100Good
Development Activity64
Maintenance36
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture82
Code Quality80
Innovation65
Learning Curve78

console is a Rust library that abstracts over terminal capabilities, giving CLI authors a single API for colored/styled text, cursor movement, terminal size detection, and reading keyboard input, working consistently across Unix, Windows, and WebAssembly targets. It automatically detects whether output is a TTY and whether colors should be enabled, following the clicolors convention, so styled output degrades gracefully when piped to a file or another program.

The crate is designed as a foundational building block for the wider Rust CLI ecosystem — it is the terminal layer underneath sibling crates like dialoguer (interactive prompts) and indicatif (progress bars), both part of the same console-rs GitHub organization. Its Term type provides direct or buffered terminal access, while Style/style() provide a fluent API for composing ANSI-styled text without manually managing escape codes.

What You Get

  • A Term type for direct or buffered access to the connected terminal (write, clear line, move cursor)
  • A style()/Style API for composing ANSI-colored and styled text with automatic TTY/color detection
  • Cross-platform support for Unix, Windows (native console APIs), and WebAssembly targets
  • Terminal size detection and Unicode-width-aware text measurement via the unicode-width feature
  • Keyboard input reading utilities (kb module) for building interactive terminal interfaces

Common Use Cases

  • Adding colored/styled output to a Rust CLI tool that automatically disables color when piped or redirected
  • Building interactive terminal prompts or progress indicators as the terminal layer under dialoguer or indicatif
  • Detecting terminal width to wrap or truncate CLI output correctly across different terminal sizes
  • Reading raw keyboard input for CLI tools that need interactive keypress handling

Under The Hood

Architecture The crate splits terminal handling by platform: unix_term.rs (422 lines) and a windows_term/ module implement OS-specific terminal control (via libc on Unix, windows-sys Win32 console APIs on Windows), unified behind the public Term type in term.rs (687 lines); ansi.rs (471 lines) handles ANSI escape-sequence parsing/generation for styling, and utils.rs (1229 lines) hosts the Style/color-detection logic including the clicolors-standard TTY detection. A wasm_term.rs stub provides a no-op/limited implementation for WebAssembly targets where no real terminal exists.

Tech Stack Rust with feature-gated dependencies: libc (optional, gated behind std), unicode-width (optional, for correct-width text measurement), windows-sys and encode_unicode only on Windows targets. The crate supports no_std-adjacent configurations via an alloc-only feature for environments without full std. Dev-dependencies include proptest for property-based testing and regex, run via a standard cargo test / Makefile-driven CI on GitHub Actions.

Code Quality The tests/ directory includes a data fixture set alongside inline unit tests within the platform-specific source modules, and CI runs across multiple platforms per the badge in the README. The codebase is organized by clear platform/concern boundaries (ansi parsing vs. term control vs. utils), each file staying focused on one responsibility, though utils.rs at 1229 lines carries a large share of the styling and color-detection logic in one place.

API Design The style() function and Term::stdout()/Term::stderr() entry points make the common case (print styled text, write a line) essentially zero-configuration, while Style::new() supports a fluent builder chain (.cyan().bold()) for more complex styling reused across multiple print calls. Being the shared terminal layer for dialoguer and indicatif means its API conventions are already familiar to a large share of the Rust CLI ecosystem, lowering the learning curve for anyone who has used those sibling crates.

Used by 8 apps in this directory

Dart
74%
AGPL 3.0

AppFlowy

Productivity · Project Management · Collaboration

75,729

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
66
Dependency
Built with
Dart74%
Rust24%
Updated 1 weeks ago
Rust
41%
Other

Hook0

Devops

1,477

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
83
Repo Health
82
Technical
70
Dependency
Built with
Rust41%
TypeScript17%
JavaScript15%
Updated today
Rust
72%
Other

iii

Developer Tools · Devops

18,604

Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.

View details
86
Repo Health
85
Technical
69
Dependency
Built with
Rust72%
TypeScript17%
Updated yesterday
TypeScript
75%
Other

Jan

AI Assistants

44,052

Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.

View details
90
Repo Health
81
Technical
66
Dependency
Built with
TypeScript75%
Rust21%
Updated today
TypeScript
95%
MIT

melty

Developer Tools · AI Code Assistants · Code Editors

5,449

The AI code editor where every chat message is a git commit you can revert, branch, or squash

View details
35
Repo Health
75
Technical
68
Dependency
Built with
TypeScript95%
Updated 1 years ago
Rust
67%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,065

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
86
Repo Health
81
Technical
66
Dependency
Built with
Rust67%
TypeScript29%
Updated today
Rust
77%
AGPL 3.0

Spacedrive

File Storage · Collaboration

38,790

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
60
Repo Health
84
Technical
65
Dependency
Built with
Rust77%
TypeScript20%
Updated 3 weeks ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Code Editors · Automation

28,833

Open-source AI code editor with direct LLM integration and data privacy

View details
49
Repo Health
84
Technical
69
Dependency
Built with
TypeScript95%
Updated 2 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search