A cli framework with the simplicity of argparse, the colors of rich, the config handling of Hydra, and without the complexity.
pip install nanoclifrom 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()# 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 -happ = 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| Flag | Meaning |
|---|---|
-p |
Print config from current node |
-g |
Print config from root (global) |
-h |
Show help |
-c PATH |
Load base config from YAML |
make dev # Install with dev deps
make test # Run tests
make pre-commit # Run all checksMIT
