Skip to main content

A Python CLI framework built on Click, with self-spacing components and Rich theming

Project description

Clicycle

CI codecov PyPI version Python Versions License: MIT

Component-based CLI rendering with automatic spacing and Rich styling

Clicycle makes beautiful CLIs easy by treating terminal output as composable components.

Installation

pip install clicycle

Quick Start

import clicycle as cc
import time

# Display header
cc.header("My App", "v2.0.0")

# Show messages
cc.info("Starting process...")

# Use a spinner
with cc.spinner("Processing..."):
    time.sleep(2)

cc.success("Complete!")

API Reference

Display Functions

# Text messages
cc.info("Information message")
cc.success("Operation successful")
cc.error("Something went wrong") 
cc.warning("Be careful")
cc.debug("Debug info")  # Only shown in verbose mode
cc.list_item("Bullet point")

# Structure
cc.header("Title", "Subtitle", "App Name")
cc.section("Section Name")

# Data display
cc.table([{"Name": "Alice", "Age": 30}], title="Users")
cc.code("print('hello')", language="python", title="Example")
cc.json({"key": "value"}, title="Config")
cc.summary([{"label": "Total", "value": 100}])

# Progress indicators (context managers)
with cc.spinner("Loading..."):
    # Your code here
    pass

with cc.progress("Processing") as prog:
    for i in range(100):
        prog.update(i, f"Item {i}")

# Multi-task progress tracking
with cc.multi_progress("Processing tasks") as progress:
    task1 = progress.add_task("Download", total=100)
    task2 = progress.add_task("Process", total=100)
    
    for i in range(100):
        progress.update(task1, advance=1)
        progress.update(task2, advance=1)

# Interactive components (with automatic fallback)
selected = cc.select("Choose an option", ["Option 1", "Option 2", "Option 3"])
selected_many = cc.multi_select("Select features", ["Auth", "API", "Cache", "Queue"])

# Group components without spacing
with cc.group():
    cc.info("These lines")
    cc.success("appear together")
    cc.warning("without spacing")

Configuration

# Configure the default instance
cc.configure(
    width=100,
    theme=cc.Theme(
        disappearing_spinners=True,  # Spinners vanish when done
        spinner_type="dots2"         # Rich spinner style
    ),
    app_name="MyApp"
)

# Direct access
cc.console.print("Rich console access")
cc.theme.icons.success = "✅"
cc.clear()  # Clear screen

Themes

Create custom themes to control appearance:

from clicycle import Theme, Icons, Typography

theme = Theme(
    # Custom icons
    icons=Icons(
        success="✅",
        error="❌",
        warning="⚠️",
        info="ℹ️",
    ),
    
    # Custom styles (Rich format)
    typography=Typography(
        header_style="bold cyan",
        success_style="bold green",
        error_style="bold red",
    ),
    
    # Spinner configuration
    disappearing_spinners=True,
    spinner_type="dots2"  # dots, line, star, etc.
)

cc.configure(theme=theme)

Component Architecture

For advanced use cases, work directly with components:

from clicycle import Clicycle
from clicycle.components.header import Header
from clicycle.components.spinner import Spinner

# Create instance
cli = Clicycle()

# Render components
cli.stream.render(Header(cli.theme, "Title"))

# Components manage their own spacing
spinner = Spinner(cli.theme, "Loading...", cli.console)
cli.stream.render(spinner)
with spinner:
    # Your code
    pass

Key Features

  • Automatic Spacing: Components intelligently manage spacing based on context
  • Disappearing Spinners: Spinners that completely vanish after completion
  • Interactive Components: Arrow-key navigation with automatic fallback
  • Rich Integration: Full support for Rich styling and formatting
  • Component Discovery: Convenience API automatically discovers all components
  • Type Safe: Full type hints for IDE support

Interactive Components

Clicycle provides smooth, responsive interactive components with vertical arrow-key navigation:

Select Menu

# Simple selection
choice = cc.select("Choose a framework:", ["React", "Vue", "Angular"])

# With descriptions and values
options = [
    {"label": "React", "value": "react", "description": "A JavaScript library"},
    {"label": "Vue", "value": "vue", "description": "The Progressive JavaScript Framework"},
    {"label": "Angular", "value": "angular", "description": "Platform for building mobile and desktop apps"}
]
choice = cc.select("Choose a framework:", options)

Multi-Select Menu

# Multiple selections with constraints
choices = cc.multi_select(
    "Select features to enable:", 
    ["Authentication", "Database", "Caching", "Queue", "Monitoring"],
    min_selection=1,
    max_selection=3
)

Navigation:

  • ↑/↓: Navigate options
  • Enter: Select/Submit
  • Space: Toggle (multi-select only)
  • q/Ctrl+C: Cancel

Features:

  • Clean vertical navigation without screen clearing
  • Automatic fallback to numbered input on non-interactive terminals
  • Real-time visual feedback
  • Proper cleanup - no leftover display artifacts

Examples

Run the interactive example menu:

python examples/menu.py

Or explore individual examples:

Basics

  • basics/hello_world.py - Simple introduction
  • basics/all_components.py - Tour of all components

Features

  • features/interactive.py - Arrow-key selection and checkboxes
  • features/spinners.py - Disappearing spinner functionality
  • features/themes.py - Custom themes (emoji, minimal, matrix)

Advanced

  • advanced/full_app.py - Complete application showcase

Quick Example

import clicycle as cc
import time

# Build a simple CLI
cc.header("My App", "v1.0.0")
cc.info("Processing data...")

with cc.spinner("Loading..."):
    time.sleep(2)
    
cc.success("Complete!")
cc.table([{"Name": "Alice", "Score": 95}, {"Name": "Bob", "Score": 87}])

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clicycle-2.1.2.tar.gz (39.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clicycle-2.1.2-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file clicycle-2.1.2.tar.gz.

File metadata

  • Download URL: clicycle-2.1.2.tar.gz
  • Upload date:
  • Size: 39.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for clicycle-2.1.2.tar.gz
Algorithm Hash digest
SHA256 efe45a86a3ec5646ff12cd5d02e0298185717d8cb74feb2d4b80565ccea5355d
MD5 e2410b344721e63f2798c14a9775ea47
BLAKE2b-256 a9c4fef858d9819dcbd0ccdab60cbbe17c1eb3fdf2b43fef0434b1ba0b2bf9f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for clicycle-2.1.2.tar.gz:

Publisher: publish.yml on Living-Content/clicycle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file clicycle-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: clicycle-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for clicycle-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 31acb4bcfee1b18472189eda48c245cfdbb32b6a3bb1917251996f6c0d83e476
MD5 766af693af62a8f4481bcd62c947d0d1
BLAKE2b-256 9f9fdde63cfd6fb30c187606156d02fbe9b27a4dcdb01ddda651e808db09be87

See more details on using hashes here.

Provenance

The following attestation bundles were made for clicycle-2.1.2-py3-none-any.whl:

Publisher: publish.yml on Living-Content/clicycle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page