Skip to content
/ nanocli Public

A cli framework with the simplicity of argparse, the colors of rich, the config handling of Hydra

License

Notifications You must be signed in to change notification settings

jaisw7/nanocli

Repository files navigation

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

About

A cli framework with the simplicity of argparse, the colors of rich, the config handling of Hydra

Resources

License

Stars

Watchers

Forks

Packages

No packages published