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:

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.5, 2.6, 2.7, 3.1, 3.2, PyPy

  • support for repeating arguments

Known problems:
  • None.

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:

$ 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 pip

  • install the program:

    # as root
    pip install entrypoint2

Ubuntu:

sudo apt-get install python-pip
sudo pip install entrypoint2

Uninstall:

# as root
pip uninstall 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.0.6.tar.gz (16.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: entrypoint2-0.0.6.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for entrypoint2-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ba72a243f2a45874ac6c762f1efa4999b75d4186e3ffed2d2ac6386709c3f8ee
MD5 ab268f561bb22471a83ca602c1921cbc
BLAKE2b-256 6f12ffea34bdecf8c43e4932897cbaa769068c8a1355b025d283707301fe40ad

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