or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

arguments.mdcolored-text.mdenglish.mdindex.mdprogress.mdprompts.mdresources.mdtext-output.mdutilities.mdvalidation.md
tile.json

tessl/pypi-clint

Python Command Line Interface Tools for colored output, progress bars, text formatting, and argument handling

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/clint@0.5.x

To install, run

npx @tessl/cli install tessl/pypi-clint@0.5.0

index.mddocs/

Clint

Python 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.

Package Information

  • Package Name: clint
  • Language: Python
  • Installation: pip install clint

Core Imports

import clint

Common 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 resources

Basic Usage

from 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
    pass

Architecture

Clint is organized into several main modules:

  • Arguments Module: Provides Args class for command-line argument parsing with filtering and grouping
  • TextUI Module: Comprehensive text output system with colors, formatting, progress indicators, and user prompts
  • Resources Module: Application directory management for cross-platform data, cache, and log storage
  • Utils Module: Path expansion, collection testing, and directory creation utilities
  • Pipes Module: Unix pipe detection and stdin data reading

The textui module includes submodules for specialized functionality: core output functions, colored text, progress bars, user prompts, input validators, column formatting, and text formatters.

Capabilities

Command Line Arguments

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): ...

Command Line Arguments

Text Output and Formatting

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): ...

Text Output and Formatting

Colored Text

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): ...

Colored Text

Progress Indicators

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): ...

Progress Indicators

User Prompts and Input

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): ...

User Prompts and Input

Input Validation

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): ...

Input Validation

Application Resources

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): ...

Application Resources

Unix Pipes and Utilities

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): ...

Unix Pipes and Utilities

English Language Helpers

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=','): ...

English Language Helpers

Types

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