Lightweight Python library for professional CLI text decoration
Enhance CLI application output with professional text decoration. Automatically adapts to your terminal width and provides simple methods for creating visually appealing formatted output.
outputdecorator is a lightweight Python library designed to enhance CLI application output with professional text decoration. It automatically adapts to your terminal width and provides simple methods for creating visually appealing formatted output.
pip install outputdecorator
from output_decorator import StringDecorator
# Center text with automatic terminal width
StringDecorator.string_decorate(text='Python', symbol='*', print_flag=True)
# Output: ************************************ Python ***********************************
# Get decorated string without printing
decorated = StringDecorator.string_decorate(text='Python', symbol='*', print_flag=False)
print(decorated) # Same output as above
# Create framed text with different border styles
frame = StringDecorator.framed_decorate(
text='Python',
top_symbol='*',
bottom_symbol='-'
)
print(frame)
"""
******
Python
------
"""
StringDecorator.string_decorate(text='', symbol='*', print_flag=True)
Creates a centered line of text padded with the specified symbol to fill the terminal width.
Parameters:
text (str) — The text to decorate (default: empty string)symbol (str) — Character used for padding (default: '*')print_flag (bool) — If True, prints directly; if False, returns the string (default: True)Returns: str or None — Decorated string if print_flag=False, otherwise None
StringDecorator.framed_decorate(text='', top_symbol='-', bottom_symbol='-')
Creates a framed text block with separate top and bottom borders.
Parameters:
text (str) — The text to frame (default: empty string)top_symbol (str) — Character for the top border (default: '-')bottom_symbol (str) — Character for the bottom border (default: '-')Returns: str — Formatted string with top border, text, and bottom border
StringDecorator.term_width()
Returns the current terminal width in columns.
Returns: int — Terminal width
Creating a banner:
StringDecorator.string_decorate(text='WELCOME', symbol='=') # =================================== WELCOME ====================================
Empty line separator:
StringDecorator.string_decorate(symbol='-') # --------------------------------------------------------------------------------
Different frame styles:
# Warning box
print(StringDecorator.framed_decorate('⚠️ WARNING ⚠️', top_symbol='!', bottom_symbol='!'))
# Success message
print(StringDecorator.framed_decorate('✓ Success!', top_symbol='=', bottom_symbol='='))
By using this software, you agree to the full disclaimer terms.
Software provided "AS IS" without warranty. You assume all risks.
Full legal disclaimer: See DISCLAIMER.md
License: BSD 3-Clause License