A micro-framework for building adaptive CLI interfaces that learn from user behavior
Project description
Pygmalion CLI Framework ๐ญ
A micro-framework for building adaptive CLI interfaces that learn from user behavior
๏ฟฝ๐ฏ Concept
Pygmalion CLI Framework transforms static command-line interfaces into self-evolving CLIs that adapt to how you use them. Unlike traditional frameworks like argparse, click, or typer, Pygmalion CLI Framework creates intelligent interfaces that:
- ๐ Track your command usage patterns
- ๐ค Suggest shortcuts and aliases automatically
- ๐ Create intelligent command workflows
- ๐ฏ Personalize help menus based on your habits
- ๐ก Discover and suggest unused features
๐ Quick Start
Installation
pip install pygmalion-cli-framework
Basic Usage
Transform any Click-based CLI into an adaptive interface:
import pygmalion
import click
@pygmalion.command()
@click.option('--count', default=1, help='Number of greetings')
@click.option('--name', prompt='Your name', help='The person to greet')
def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for _ in range(count):
click.echo(f'Hello, {name}!')
if __name__ == '__main__':
hello()
Advanced Example
import pygmalion
import click
# Initialize Pygmalion CLI Framework with custom settings
app = pygmalion.PygmalionApp(
name="myapp",
storage_backend="sqlite", # or "json"
suggestion_threshold=3, # suggest after 3 uses
)
@app.command()
@click.option('--verbose', '-v', is_flag=True, help='Verbose output')
@click.option('--format', type=click.Choice(['json', 'csv', 'table']),
default='table', help='Output format')
def export(verbose, format):
"""Export data in various formats."""
click.echo(f"Exporting in {format} format...")
if verbose:
click.echo("Verbose mode enabled")
@app.command()
@click.argument('filename')
@click.option('--backup', is_flag=True, help='Create backup before processing')
def process(filename, backup):
"""Process a file with optional backup."""
if backup:
click.echo(f"Creating backup of {filename}")
click.echo(f"Processing {filename}")
if __name__ == '__main__':
app.run()
โจ Features
1. Command Tracking
Pygmalion CLI Framework automatically tracks:
- Command frequency and timestamps
- Option combinations used
- Command sequences and patterns
- User preferences over time
2. Smart Alias Suggestions
After detecting repetitive command patterns, Pygmalion CLI Framework will suggest:
$ myapp export --format json --verbose
# After 3+ uses, Pygmalion CLI Framework suggests:
๐ก You often use 'export --format json --verbose'
Would you like to create an alias? [y/N]: y
Alias name [export-json-verbose]: ejv
โ
Alias 'ejv' created!
$ myapp ejv # Now works as shortcut
3. Workflow Builder
Detects command sequences and suggests macros:
$ myapp process data.csv --backup
$ myapp export --format json
# Pygmalion CLI Framework detects pattern and suggests:
๐ก You often run 'process' followed by 'export'
Create a workflow? [y/N]: y
Workflow name: process-and-export
โ
Workflow created!
4. Adaptive Help System
Your most-used commands appear first in help:
$ myapp --help
Your Most Used Commands:
export Export data (used 15 times)
process Process files (used 12 times)
Other Commands:
config Configure settings
init Initialize project
๐ก Try: myapp export --format csv (you haven't used CSV format yet!)
5. Usage Analytics
$ myapp --stats
๐ Pygmalion CLI Framework Usage Analytics
Most Used Commands:
export (45%) โโโโโโโโโโโโโโโโโโโโ
process (32%) โโโโโโโโโโโโโโ
config (23%) โโโโโโโโโโ
Suggested Optimizations:
โข Create alias for 'export --format json --verbose' (used 8 times)
โข Try 'process --parallel' for faster processing
โข You haven't used 'config --advanced' yet
๐๏ธ Architecture
Pygmalion CLI Framework works as a wrapper around Click, extending it with intelligence:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your CLI App โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Pygmalion CLI Framework Layer โ
โ โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ โ
โ โ Tracker โ Suggestions โ โ
โ โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโค โ
โ โ Storage โ Analytics โ โ
โ โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Click Framework โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ๏ธ Configuration
Storage Options
JSON (Default)
app = pygmalion.PygmalionApp(storage_backend="json")
# Creates ~/.pygmalion/myapp.json
SQLite (Recommended for heavy use)
app = pygmalion.PygmalionApp(storage_backend="sqlite")
# Creates ~/.pygmalion/myapp.db
Customization
app = pygmalion.PygmalionApp(
name="myapp",
storage_backend="sqlite",
storage_path="./custom/path/",
suggestion_threshold=5, # Suggest aliases after 5 uses
workflow_threshold=3, # Suggest workflows after 3 sequences
analytics_enabled=True, # Enable usage analytics
suggestions_enabled=True, # Enable smart suggestions
help_personalization=True, # Personalize help menus
)
๐งช Testing
Run the test suite:
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=pygmalion
๐ Example Demo
Try the included demo application:
pygmalion-demo --help
The demo showcases all Pygmalion features with a sample file management CLI.
๐ค Contributing
Contributions are welcome! Please read our Contributing Guide for details.
Development Setup
git clone https://github.com/Okymi-X/pygmalion.git
cd pygmalion
pip install -e ".[dev]"
Running Tests
pytest
black pygmalion tests
flake8 pygmalion tests
mypy pygmalion
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
- Built on top of the excellent Click framework
- Inspired by adaptive user interfaces and machine learning principles
- Thanks to all contributors and early adopters
Transform your CLI from static to smart with Pygmalion! ๐ญโจ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygmalion_cli_framework-0.1.2.tar.gz.
File metadata
- Download URL: pygmalion_cli_framework-0.1.2.tar.gz
- Upload date:
- Size: 40.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8bba60d69f5d7a5e8f4533bc6db08f04ce08c0936a11d36eb9da188ae441910
|
|
| MD5 |
f36908498d1f75b1333bf742723aaa2b
|
|
| BLAKE2b-256 |
2a335fbfb5620151b06fb3d96e0e6a05cd1eee01ef417b6d723996e883ac1ebf
|
File details
Details for the file pygmalion_cli_framework-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pygmalion_cli_framework-0.1.2-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea534dc6aba15df3f351bf6a199d394f730384f4c321b519f91a39be2cb16e91
|
|
| MD5 |
71682faec3414948fb6cccb7ab986f17
|
|
| BLAKE2b-256 |
d560fe78cd5b58a9269aa4da329c1e7c975651f17c8683959d7152e406ef839f
|