Python Command Line Interface Tools for colored output, progress bars, text formatting, and argument handling
npx @tessl/cli install tessl/pypi-clint@0.5.0Python Command Line Interface Tools that provide comprehensive functionality for creating rich terminal applications. Clint offers colored output, progress bars, indented text formatting, column-based layouts, argument handling, user prompts, and application directory management with built-in cross-platform compatibility.
pip install clintimport clintCommon patterns for specific functionality:
from clint.textui import puts, colored, indent
from clint.arguments import Args
from clint.textui.progress import bar
from clint.textui import prompt
from clint import resourcesfrom clint.textui import puts, colored, indent
from clint.arguments import Args
# Colored output with automatic TTY detection
puts(colored.red('Error: Something went wrong'))
puts(colored.green('Success: Operation completed'))
# Nested indentation with context manager
puts('Root level text')
with indent(4):
puts('Indented text')
with indent(4, quote='> '):
puts('Quoted and nested text')
# Command line argument parsing
args = Args()
first_arg = args.get(0) # Get first argument or None
if 'verbose' in args:
puts('Verbose mode enabled')
# Progress bars for iterables
from clint.textui.progress import bar
items = range(100)
for item in bar(items, label='Processing: '):
# Process each item
passClint is organized into several main modules:
Args class for command-line argument parsing with filtering and groupingThe textui module includes submodules for specialized functionality: core output functions, colored text, progress bars, user prompts, input validators, column formatting, and text formatters.
Comprehensive command-line argument parsing with filtering, grouping, and file/flag detection. The Args class provides chainable methods for finding, filtering, and extracting arguments with support for complex argument patterns.
class Args:
def __init__(self, args=None, no_argv=False): ...
def get(self, x): ...
def contains(self, x): ...
def first(self, x): ...
def all_with(self, x): ...
def grouped(self): ...
def flags(self): ...
@property
def files(self): ...Core text output functions with indentation context management, colored text support, and cross-platform compatibility. Includes puts/puts_err functions and indent context managers for nested text formatting.
def puts(s='', newline=True, stream=STDOUT): ...
def puts_err(s='', newline=True, stream=STDERR): ...
def indent(indent=4, quote=''): ...
def columns(*cols, **kwargs): ...Rich colored text output with automatic TTY detection and cross-platform terminal color support. Provides color functions and ColoredString class with string operation compatibility.
def red(string, always=False, bold=False): ...
def green(string, always=False, bold=False): ...
def blue(string, always=False, bold=False): ...
class ColoredString:
def __init__(self, color, s, always_color=False, bold=False): ...Progress bars, dots, and mill/spinner indicators for long-running operations. Supports both iterator wrapping and manual progress updates with customizable appearance and automatic terminal width detection.
def bar(it, label='', width=32, hide=None, expected_size=None, every=1): ...
def dots(it, label='', hide=None, every=1): ...
class Bar:
def __init__(self, label='', width=32, hide=None): ...
def show(self, progress, count=None): ...Interactive user prompts with validation, including yes/no questions, text input with validation, and multiple choice options. Supports batch mode for automated testing and custom validators.
def yn(prompt, default='y', batch=False): ...
def query(prompt, default='', validators=None, batch=False): ...
def options(prompt, options, default=None, batch=False): ...Comprehensive input validation system with regex, path, file, integer, and option validators. Extensible validation framework with custom error messages and validator chaining.
class RegexValidator:
def __init__(self, regex=None, message=None): ...
class PathValidator:
def __init__(self, message=None): ...
class IntegerValidator:
def __init__(self, message=None): ...Cross-platform application directory management for user data, site data, cache, and log directories. Provides file operations and subdirectory management with automatic directory creation.
def init(vendor, name): ...
class AppDir:
def write(self, filename, content, binary=False): ...
def read(self, filename, binary=False): ...
def sub(self, path): ...Unix pipe detection for stdin data, path expansion utilities, collection testing, and directory creation helpers. Includes string manipulation functions for delimiter splitting and chunking.
def piped_in(): ...
def expand_path(path): ...
def is_collection(obj): ...
def mkdir_p(path): ...English language string joining with Oxford comma support and customizable conjunctions. Useful for generating human-readable lists and messages.
def join(l, conj='and', im_a_moron=False, separator=','): ...class Args:
"""CLI Argument management class with filtering and grouping capabilities."""
pass
class ColoredString:
"""Enhanced string class that maintains color information and string operations."""
pass
class Bar:
"""Progress bar implementation with customizable appearance and timing."""
pass
class AppDir:
"""Application directory manager with file operations and path management."""
pass
class ValidationError(Exception):
"""Exception raised during input validation failures."""
pass