k3shell
Shell command dispatcher with nested subcommand support.
k3shell is a component of pykit3 project: a python3 toolkit set.
Installation
pip install k3shell
Quick Start
import k3shell
import sys
# Define command structure with nested subcommands
arguments = {
'echo': (
lambda x: sys.stdout.write(repr(x)),
('x', {'nargs': '+', 'help': 'input message'}),
),
'math': {
'add': (
lambda x, y: print(x + y),
('x', {'type': int}),
('y', {'type': int}),
),
},
}
# Run command dispatcher
k3shell.command(**arguments)
Usage:
python my_cli.py echo hello world
python my_cli.py math add 1 2
API Reference
k3shell
Name
k3shell
Status
The library is considered production ready.
License
The MIT License (MIT) - Copyright (c) 2015 Zhang Yanpo (张炎泼)