Introduction
Termline provides human-friendly terminal output for applications and development tools built with the Lesli Framework.
It exposes a small Ruby API for semantic messages, colors, icons, structured metadata, lists, tables, and separators. Termline has no application-framework dependency, so it can also be used by standalone Ruby applications, scripts, Rake tasks, and command-line tools.
Why Termline?
Termline provides:
- Consistent terminal output across the Lesli ecosystem
- Semantic info, success, warning, and danger messages
- Colored icons, labels, and timestamps
- Structured key-value metadata
- Ordered and unordered lists
- Terminal-aware tables with alignment and truncation
- Reusable titles, detail blocks, spacing, and adaptive separators
- A lightweight implementation with no runtime dependencies
Quick Start
Requirements
- Ruby 2.7.2 or newer
Termline is framework-independent and does not require Rails.
Installation
Add Termline to the application:
bundle add termlineRequire the gem when Bundler does not load it automatically:
require "termline"Usage
Messages
require "termline"
Termline.msg "Hello world"
Termline.info "Server started"
Termline.success "All tests passed"
Termline.warning "Low disk space"
Termline.danger "Something failed"Every semantic helper accepts multiple messages and prints each one on its own line:
Termline.info "Loading configuration", "Connecting to database"Attach structured metadata with keyword arguments:
Termline.success "Compiled application.tailwind.css", size: "1.4 KB"
Termline.info "Connected", adapter: "postgres", duration: "12ms"Metadata is rendered in a compact, readable form such as adapter=postgres duration=12ms.
Override the default tag, icon, or timestamp when the output needs a different presentation:
Termline.info "User authenticated", tag: "AUTH:", icon: :star
Termline.success "Cache warmed", time: falseTimestamp defaults can also be configured once for the application:
Termline.configure do |config|
config.timestamps = false
config.timestamp_format = "%H:%M:%S"
endLists and tables
Termline.list("Rails", "Lesli", "Tailwind")
Termline.list("Database", "Cache", icon: :success, color: :green)
Termline.ordered_list("Install", "Configure", "Run", start: 1)
Termline.table([
{ name: "Luis", role: "Admin", status: "Active" },
{ name: "Ana", role: "Developer", status: "Pending" }
], align: { name: :left, status: :center })Tables fit the available terminal width, truncate long values with …, and right-align numeric columns automatically.
Titles and details
Termline.title "Deployment"
Termline.details environment: "production", version: "1.4.0"
Termline.details({ status: "ready", workers: 4 }, icons: { status: :success, workers: :info })Spacing and separators
Termline.br
Termline.br(2)
Termline.line
Termline.line(character: "=")Without arguments, line adapts to the current terminal width.
Public API
| Helper | Purpose |
|---|---|
Termline.m |
Print one or more unformatted values |
Termline.msg |
Print neutral messages with optional metadata |
Termline.info |
Print informational messages |
Termline.success |
Print successful outcomes |
Termline.warning |
Print warnings |
Termline.danger |
Print errors or failed outcomes |
Termline.alert |
Print a high-visibility alert |
Termline.deprecation |
Print a deprecation warning |
Termline.list |
Print an unordered styled list |
Termline.ordered_list |
Print a numbered list |
Termline.table |
Print width-aware arrays, hashes, or Active Record relations as a table |
Termline.title |
Print a terminal-width section title |
Termline.details |
Print an aligned block of labeled details |
Termline.br |
Print blank lines |
Termline.line |
Print a visual separator |
Termline.color |
Print a terminal-width background color bar when ANSI is enabled |
Termline.configure |
Configure output, ANSI mode, width, and timestamp defaults |
Message, list, table, and spacing helpers write to the configured output, which defaults to $stdout. See the focused guides for all supported options and lower-level builders:
Output configuration
Termline writes to $stdout and enables ANSI styles automatically for interactive terminals. Redirect the output or override ANSI rendering when needed:
require "stringio"
buffer = StringIO.new
Termline.output = buffer
Termline.ansi = false
Termline.success "Saved", time: false
buffer.string # => "✔ SUCCESS: Saved\n"The supported ANSI modes are :auto, true, and false. Automatic mode disables escape sequences when the output is not a TTY, when TERM=dumb, or when the NO_COLOR environment variable is present.
The terminal width is detected when content is rendered and falls back to 80 columns. It can be overridden explicitly:
Termline.width = 100Message timestamps are enabled by default. Use Termline.timestamps = false to disable them globally, and time: true or time: false to override the setting for one message.
Development
Clone the repository and install its dependencies:
git clone https://github.com/LesliTech/Termline.git
cd Termline
bundle installTo use local source from a Lesli development workspace, reference it from the host application's Gemfile:
gem "termline", path: "gems/Termline"Tests
Run the default test task from the Termline directory:
bundle exec rakeThe suite uses LesliTesting for the shared Lesli reporter and coverage configuration. Coverage is opt-in:
COVERAGE=true bundle exec rakeUse QUIET=true to suppress the line printed for every individual test:
QUIET=true COVERAGE=true bundle exec rakeRun the executable examples to preview the available output styles:
bundle exec ruby test/demo_termline.rbDocumentation
- Lesli website
- Termline documentation
- Testing guide
- Roadmap and P3 ToDo
- Releases and changelog
- Issue tracker
- Source code
Community
License
Copyright (c) 2026, Lesli Technologies, S. A.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
The complete license text is available in the license file.
