Skip to main content

easy to use command-line interface for python modules, fork of entrypoint

Project description

entrypoint2 is an easy to use argparse based command-line interface for python modules, fork of entrypoint. It translates function signature and documentation to argparse configuration.

Links:

Travis Coveralls Latest Version Supported Python versions License Documentation

Goals:

  • simplicity: only one decorator to add to existing code

Features:

  • good for protoyping or simple CLI

  • generate CLI parameters from function signature

  • generate CLI documentation from python documentation

  • the decorated function has the same behavior as without the entrypoint2 decorator

  • boolean parameters are toggle flags (e.g. --verbose)

  • function signature is preserved so it can be called both from command-line and external module

  • function name, doc and module are preserved so it can be used with sphinx autodoc

  • sphinx autodoc documentation style is supported: :param x: this is x

  • automatic --version flag, which prints version variable from the current module (__version__, VERSION, ..)

  • automatic --debug flag, which turns on logging

  • short flags are generated from long flags automatically (e.g. --parameter -> -p)

  • unit tests

  • supported python versions: 2.7, 3.6, 3.7, 3.8

  • support for repeating arguments

Similar projects:

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:

$ python3 -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:

$ python3 -m entrypoint2.examples.hello --version
3.2

Installation

install:

pip install entrypoint2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

entrypoint2-0.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

entrypoint2-0.1-py2.py3-none-any.whl (10.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file entrypoint2-0.1.tar.gz.

File metadata

  • Download URL: entrypoint2-0.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.17

File hashes

Hashes for entrypoint2-0.1.tar.gz
Algorithm Hash digest
SHA256 7594e2d6e654dd9717ad28eba91092844b8578debceb25061da8cb5975c5408e
MD5 072ed7f639aef5b8065ce4d8871b32f9
BLAKE2b-256 0e8cb31914b4d4b73b9825dda854f3a162fa7442d76fd91aadf92d0337841180

See more details on using hashes here.

File details

Details for the file entrypoint2-0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: entrypoint2-0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.17

File hashes

Hashes for entrypoint2-0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c8d392a3972119094eb97349653f00447915a7779bc0c1c275111084a930d6d8
MD5 c56bd54777d35f0a04966d3eb48588b0
BLAKE2b-256 2a87a849caae84388ccf8932583a2e204fcb25e2b18fdd2893b3c6e788d11ea0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page