Skip to main content

Recursive hierarchical CLI framework with typed configs and YAML synthesis

Project description

NanoCLI

A cli framework with the simplicity of argparse, the colors of rich, the config handling of Hydra, and without the complexity.

NanoCLI Demo

Core Model

CLI = YAML Tree
├── commands (leaf nodes)
└── groups (subtrees)

Quick Start

from dataclasses import dataclass
from nanocli import group

@dataclass
class TrainConfig:
    epochs: int = 100
    lr: float = 0.001

app = group()

@app.command()
def train(cfg: TrainConfig):
    print(f"Training for {cfg.epochs} epochs")

if __name__ == "__main__":
    app()

Usage

# Run command
python app.py train
python app.py train epochs=200

# Hydra-style overrides at root level
python app.py train.epochs=200 -p

# Print config: -p (local), -g (global from root)
python app.py train -p
python app.py data download -g

# Load YAML config
python app.py -c config.yml train

# Help
python app.py -h
python app.py train -h

Nested Groups

app = group()

@app.command()
def train(cfg: TrainConfig):
    ...

data = app.group("data", help="Data commands")

@data.command()
def download(cfg: DownloadConfig):
    ...
python app.py data download
python app.py data download dataset=coco -p
python app.py data download dataset=coco -g  # prints full tree

Flags

Flag Meaning
-p Print config from current node
-g Print config from root (global)
-h Show help
-c PATH Load base config from YAML

Development

make dev          # Install with dev deps
make test         # Run tests
make pre-commit   # Run all checks
make lint-fix     # Fix lint issues
make type-check   # Type check

License

MIT

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

nanocli-0.1.0.tar.gz (372.8 kB view details)

Uploaded Source

Built Distribution

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

nanocli-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file nanocli-0.1.0.tar.gz.

File metadata

  • Download URL: nanocli-0.1.0.tar.gz
  • Upload date:
  • Size: 372.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for nanocli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f2ebbf7e863d50c09fac9093b41d0ca10c4656168f4e6d595d8fc14cc6743f5e
MD5 c90d983a8bc820fa6d0ada9e9dab4e8b
BLAKE2b-256 4b62ffe47339bf67a34541abbfba0967ef15126745f3321f3796014d6cd12142

See more details on using hashes here.

File details

Details for the file nanocli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nanocli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for nanocli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0db854c24d447215e1338adb419e07e10231fc2dda96e31e6d8eca7b13aa3b3
MD5 24d4a5efe91e6280c1c709919b98b55a
BLAKE2b-256 bdc408dcbc595206c0fe65d75af99a836e11e5700f4bbc6a4fab5c01f42f56f2

See more details on using hashes here.

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