The command-tree is a lightweight framework to build multi level command line interfaces by using the python builtin argparse module.
- The main objectives are:
- Full argparse compatibility.
- Use as litle as possible code to build the tree, but preserve the argparse flexibiltiy.
- The class and function structure must looks as the cli tree.
- Decorators, decorators everywhere. We love decorators, so we use as often as possible.
Full documentation: http://command-tree.readthedocs.io/
pip install command-tree
from command_tree import CommandTree
tree = CommandTree()
@tree.root()
class Root(object):
@tree.leaf()
@tree.argument()
def command1(self, arg1):
"""divides the arguments by 2"""
return int(arg1) / 2
@tree.leaf(help = "multiplies the argument by 2")
@tree.argument()
def command2(self, arg1):
return int(arg1) * 2
print(tree.execute())
$ python3 example.py command2 21 42
More examples: http://command-tree.readthedocs.io/en/latest/#examples
pip install -r docs/requirements.txt ./build-docs.sh
pip install -r test/requirements.txt pytest