Cli is a Python library to help create command-line interfaces with ease.
pip install git+https://github.com/HashLDash/cli
from cli import cli
@cli("hello")
def hello():
''' This is a test command '''
print("Hello, World!")
@cli("add <int:a> <int:b>")
def add(a, b):
print(f'Adding {a} + {b} = {a+b}')
This would add two commands (and automagically a help command) that can be called like:
$ python command.py hello
Hello, World!
$ python command.py add 5 4
Adding 5 + 4 = 9
$ python command.py help
command.py help
hello - This is a test command
You can also add shebangs, ommit the extension and link to your path to create a command for using like:
$ command hello
Hello, World!
$ command add 5 4
Adding 5 + 4 = 9
You can also pass keyword arguments, and those will be delivered to your function aswell.
This is still in development. The following is planned:
- Increase supported types
Feel free to open issues for bugs and feature requests.
PRs are welcome too!
Enjoy :)