Metadata-Version: 2.4
Name: miyamura80-cli-template
Version: 0.1.1
Summary: 🪛 CLI tool template (python) with batteries included. Auto-install, updates, linting, dead code analysis, and a whole lot more.
Project-URL: Homepage, https://github.com/Miyamura80/CLI-Template
Project-URL: Repository, https://github.com/Miyamura80/CLI-Template
Project-URL: Issues, https://github.com/Miyamura80/CLI-Template/issues
Author-email: Miyamura80 <eitomiyamura@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Eito Miyamura
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: cli,template,tooling,typer,uv
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Requires-Python: >=3.12
Requires-Dist: deptry>=0.23.0
Requires-Dist: dspy>=3.1.2
Requires-Dist: google-genai>=1.60.0
Requires-Dist: human-id>=0.2.0
Requires-Dist: import-linter>=2.1.1
Requires-Dist: keyring>=25.0.0
Requires-Dist: langfuse>=3.12.1
Requires-Dist: litellm>=1.59.8
Requires-Dist: loguru>=0.7.3
Requires-Dist: numpy>=2.2.2
Requires-Dist: openfeature-sdk>=0.7.1
Requires-Dist: packaging>=24.0
Requires-Dist: pillow>=12.1.0
Requires-Dist: pydantic-settings>=2.7.1
Requires-Dist: pydantic>=2.10.6
Requires-Dist: pylint>=3.3.3
Requires-Dist: pytest-cov>=7.0.0
Requires-Dist: pytest-env>=1.2.0
Requires-Dist: pytest-repeat>=0.9.3
Requires-Dist: pytest-xdist>=3.6.1
Requires-Dist: pytest>=8.3.4
Requires-Dist: python-dotenv>=1.2.1
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: questionary
Requires-Dist: rich>=14.3.1
Requires-Dist: scrubadub>=2.0.1
Requires-Dist: tenacity>=9.0.0
Requires-Dist: termcolor>=2.5.0
Requires-Dist: ty>=0.0.14
Requires-Dist: typer
Requires-Dist: vulture>=2.14
Description-Content-Type: text/markdown

# cli-template

<p align="center">
  <img src="media/banner.png" alt="2" width="400">
</p>

<p align="center">
<b>Batteries-included Python CLI template. Auto-discovery commands, global flags, output formatting, self-update, and a whole lot more.</b>
</p>

<p align="center">
  <a href="#key-features">Key Features</a> •
  <a href="#quick-start">Quick Start</a> •
  <a href="#cli-usage">CLI Usage</a> •
  <a href="#adding-commands">Adding Commands</a> •
  <a href="#configuration">Configuration</a> •
  <a href="#credits">Credits</a> •
  <a href="#about-the-core-contributors">About the Core Contributors</a>
</p>

<p align="center">
  <img alt="Project Version" src="https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FMiyamura80%2FCLI-Template%2Fmain%2Fpyproject.toml&query=%24.project.version&label=version&color=blue">
  <img alt="Python Version" src="https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FMiyamura80%2FCLI-Template%2Fmain%2Fpyproject.toml&query=%24.project['requires-python']&label=python&logo=python&color=blue">
  <img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/Miyamura80/CLI-Template">
  <img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/Miyamura80/CLI-Template/a_test_target_tests.yml?branch=main">

</p>

---

<p align="center">
  <img src="media/cli_demo.gif" alt="CLI Demo" width="600">
</p>


## Key Features

Opinionated Python CLI template for fast development. The `saas` branch extends `main` with web framework, auth, and payments.

| Feature | `main` | `saas` |
|---------|:------:|:------:|
| Auto-discovery command system | ✅ | ✅ |
| Interactive fallback prompts | ✅ | ✅ |
| Shell completions | ✅ | ✅ |
| Self-update | ✅ | ✅ |
| Anonymous telemetry with opt-out | ✅ | ✅ |
| UV + Pydantic config | ✅ | ✅ |
| CI/Linters (Ruff, Vulture) | ✅ | ✅ |
| Pre-commit hooks (prek) | ✅ | ✅ |
| LLM (DSPY + LangFuse Observability) | ✅ | ✅ |
| FastAPI + Uvicorn | ❌ | ✅ |
| SQLAlchemy + Alembic | ❌ | ✅ |
| Auth (WorkOS + API keys) | ❌ | ✅ |
| Payments (Stripe) | ❌ | ✅ |
| Ralph Wiggum Agent Loop | ✅ | ✅ |

[Full comparison](manual_docs/branch_comparison.md)

## Quick Start

```bash
make onboard              # interactive setup (rename, deps, env, hooks)
uv sync                   # install deps
uv run mycli --help       # see all commands
uv run mycli greet Alice  # run a command
uv run mycli init my_command  # scaffold a new command
```

## CLI Usage

Global flags go **before** the subcommand:

| Flag | Short | Description |
|---|---|---|
| `--verbose` | `-v` | Increase output verbosity |
| `--quiet` | `-q` | Suppress non-essential output |
| `--debug` | | Show full tracebacks on error |
| `--format` | `-f` | Output format: `table`, `json`, `plain` |
| `--dry-run` | | Preview actions without executing |
| `--version` | `-V` | Print version and exit |

```bash
uv run mycli --format json config show     # JSON output
uv run mycli --dry-run greet Bob           # preview without executing
uv run mycli --verbose greet Alice         # detailed output
```

## Adding Commands

Drop a Python file in `commands/` and it is auto-discovered.

**Single command** - export a `main()` function:

```python
# commands/hello.py
from typing import Annotated
import typer

def main(name: Annotated[str, typer.Argument(help="Who to greet.")]) -> None:
    """Say hello."""
    typer.echo(f"Hello, {name}!")
```

```bash
uv run mycli hello World   # Hello, World!
```

**Subcommand group** - export `app = typer.Typer()`:

```python
# commands/db.py
import typer

app = typer.Typer()

@app.command()
def migrate() -> None:
    """Run migrations."""
    ...
```

```bash
uv run mycli db migrate
```

Or scaffold with: `uv run mycli init my_command --desc "Does something"`.

## Configuration

```python
from common import global_config

# Access config values from common/global_config.yaml
global_config.example_parent.example_child

# Access secrets from .env
global_config.OPENAI_API_KEY
```

CLI config inspection:

```bash
uv run mycli config show                           # full config
uv run mycli config get llm_config.cache_enabled   # single value
uv run mycli config set logging.verbose false      # write override
```

[Full configuration docs](manual_docs/configuration.md)

## Credits

This software uses the following tools:
- [Cursor: The AI Code Editor](https://cursor.com)
- [uv](https://docs.astral.sh/uv/)
- [Typer: CLI framework](https://typer.tiangolo.com/)
- [Rich: Terminal formatting](https://rich.readthedocs.io/)
- [prek: Rust-based pre-commit framework](https://github.com/j178/prek)
- [DSPY: Pytorch for LLM Inference](https://dspy.ai/)
- [LangFuse: LLM Observability Tool](https://langfuse.com/)

## About the Core Contributors

<a href="https://github.com/Miyamura80/CLI-Template/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=Miyamura80/CLI-Template" />
</a>

Made with [contrib.rocks](https://contrib.rocks).
