Skip to main content

Recursive hierarchical CLI framework with typed configs and YAML synthesis

Project description

NanoCLI

PyPI version

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

NanoCLI Demo

Installation

pip install nanocli

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

# Load YAML config
python app.py -c examples/train_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 path=/data -p
python app.py data download -g  # prints full tree from root

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

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.1.tar.gz (324.1 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.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nanocli-0.1.1.tar.gz
  • Upload date:
  • Size: 324.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nanocli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0c2a47aaf06c538dfbf54eb865435cbf6a58ebad73d2c78d8f71e2f4e250eacb
MD5 3e4317567af44a59c228b60dbbbb2bef
BLAKE2b-256 766f6c6d16f82f55af6029a7fe1c310522e7249f7cbd933328eaf218f2b57032

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanocli-0.1.1.tar.gz:

Publisher: publish.yml on jaisw7/nanocli

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

File details

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

File metadata

  • Download URL: nanocli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nanocli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 205b0d3fe8e72d26a96957667da74bd769d53e14795342c2c83b4ab36ab1200b
MD5 eb2624dd5541d9afc7a95ebe32337444
BLAKE2b-256 8aef498a1907f838e9888a7145b7a0a61e9ed27891b5c0b2aa6a79f286118013

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanocli-0.1.1-py3-none-any.whl:

Publisher: publish.yml on jaisw7/nanocli

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