entrypoint2
Entrypoint2 is an easy-to-use command-line interface for Python modules. It translates function signatures and documentation directly into `argparse` configurations, simplifying CLI creation. The current version is 1.1. Releases appear to be infrequent and event-driven, rather than on a fixed cadence.
Warnings
- breaking Older versions of `entrypoint2` or its predecessor, `entrypoint`, had known issues with Python 3 compatibility. Version 1.1 and later explicitly support Python 3.6 to 3.12 and are Python 3 'only'. Projects targeting Python 2 should use older, unmaintained versions at their own risk.
- gotcha Parameter type conversion is inferred from default argument values in the function signature. If a parameter has no default value, it is treated as a string by default. This can lead to unexpected type errors at runtime if a different type is expected and no default is provided.
- gotcha Automatic short flags (e.g., `-m` for `--message`) are generated from the first letter of a parameter. However, if multiple parameters start with the same letter, only the first one encountered will receive a short flag. Subsequent parameters with the same initial letter will not have a short flag.
- gotcha The `--version` flag automatically attempts to read the version from `__version__`, `VERSION`, or `version` variables defined in the module. If multiple such variables exist, the order of precedence is not strictly documented and might lead to an unexpected version string being displayed.
Install
-
pip install entrypoint2
Imports
- entrypoint
from entrypoint2 import entrypoint
Quickstart
from entrypoint2 import entrypoint
@entrypoint
def hello(message):
print(f"Hello, {message}!")
# To run from command line:
# python -m your_module_name hello World
# python -m your_module_name hello --help