entrypoint2 is an easy to use command-line interface for Python modules, a fork of entrypoint.
Basic usage:
Example:
from entrypoint2 import entrypoint
__version__ = '3.2'
@entrypoint
def add(one, two=4, three=False):
''' This function adds three numbers.
one: first number to add
two: second number to add
'''
Generated help:
$ python -m entrypoint2.examples.hello --help
usage: hello.py [-h] [-t TWO] [--three] [--version] [--debug] one
This function adds two number.
positional arguments:
one first number to add
optional arguments:
-h, --help show this help message and exit
-t TWO, --two TWO second number to add
--three
--version show program's version number and exit
--debug set logging level to DEBUG
Printing version:
python -m entrypoint2.examples.hello --version
3.2
Installation:
General
install setuptools or pip
install the program:
if you have setuptools installed:
# as root
easy_install entrypoint2
if you have pip installed:
# as root
pip install entrypoint2
Ubuntu
sudo apt-get install python-setuptools
sudo easy_install entrypoint2
Uninstall
# as root
pip uninstall entrypoint2
Product's homepage
Here are some key features of "entrypoint2":
· function signature is preserved so it can be called both from command-line and external module
· automatic --version flag, which prints version variable from the current module (__version__, VERSION, ..)
· automatic --debug flag, which turns on logging
· short flags are generated automatically (e.g. --parameter -> -p)
· unit tests
Requirements:
· Python
Limitations:
· Python 3 is not supported
· only @entrypoint is tested
· @entrypoint decorator changes function name, doc; this can be resolved if necessary
· Autocompletion is not supported