Beautiful Terminal Output
A tool that prints clear, well-formatted output feels professional and is easier to use. larztui and larzcolor give you tables, panels, rules and colour - width-aware and pipe-safe.
The difference between a script that dumps raw text and a tool that presents clean, formatted output is the difference between something that feels hacky and something that feels professional. larztui and larzcolor give your CLI polished output - aligned tables, bordered panels, titled rules and colour - and crucially, they behave correctly when output is piped or redirected.
Structure and colour
Present information the way it deserves: tables for tabular data, panels for grouped info, colour for emphasis and status.
from larztui import table, panel, rule
from larztui import style
print(rule('Results'))
print(table(['Name', 'Status'], [['build', 'ok'], ['tests', 'ok']]))
print(panel('All checks passed.', title='Summary'))
print(style('done', fg='green', bold=True))| Widget | For |
|---|---|
| table | Aligned rows/columns of data |
| panel | A bordered box of grouped info |
| rule | A titled section divider |
| style | Coloured/bold emphasis and status |
Well-structured output isn't just prettier - it's genuinely easier to read and act on, which is the whole point of a tool's output.
Correct when it counts
The subtle, important part: output must stay aligned even with colour, and colour must vanish when output isn't a terminal (piped to a file or another command).
Polish your tool
- Use structure - tables/panels/rules beat walls of text.
- Use colour for meaning - status, emphasis, warnings.
- Stays aligned - width measured ignoring ANSI codes.
- Pipe-safe - colour auto-disables off a terminal.
๐ฏ Key takeaways
- Clean, structured output makes a tool feel professional and easier to use.
- larztui gives tables, panels, rules and colour; use structure and colour to convey meaning.
- It's width-aware - measures visible width ignoring colour codes - so styled tables stay aligned.
- Colour auto-disables when output isn't a terminal (or NO_COLOR), keeping piped output clean.
Frequently asked
Why does colour need to disappear when output is piped?
Because colour is produced by invisible ANSI escape codes that a terminal interprets as formatting, but that appear as ugly gibberish (like ^[[32m) when the output goes somewhere that doesn't interpret them - a file, a log, or another program in a pipeline. If your tool always emitted colour, piping its output would corrupt it with these codes, breaking downstream processing. So well-behaved CLIs detect whether output is going to a real terminal and only emit colour then, and also honour the NO_COLOR convention. larztui does this automatically, so your tool is pretty for humans and clean for machines without you having to handle the distinction.
My table columns don't line up when I add colour - why?
Because naive width calculations count the invisible colour codes as if they were visible characters, so a coloured cell looks 'wider' to the code than it appears on screen, throwing off the alignment. The fix is to measure the visible width - the printed characters only, ignoring the ANSI escape sequences - when padding columns. larztui does exactly this, so tables and panels stay perfectly aligned even when cells are styled with colour or bold. It's a small but common bug in hand-rolled table output, and it's handled for you here, which is a big part of why the results look professional.
Related lessons
Turn a Function Into a CLI
The core move: larzcli turns a plain Python function into a full command-line tool - argumโฆ
Build CLI Tools with LarzInteractive Prompts & Progress
Great CLIs talk with the user: asking questions when needed, and showing progress on long โฆ
Build CLI Tools with LarzPackage & Ship Your CLI
A tool only helps others if they can install it. Packaging your CLI so it installs with piโฆ