Skip to main content

Version License Python Contributors

When developing a new package, there are python functions that you want to make also available from the command line. To do so, an additional function is needed; a specially designed command-line-function which is then referenced in the setup.py file, inside the entry_points key. This command-line-function is special indeed, since it cannot have arguments (it uses instead sys.stdin or sys.argv as inputs) and cannot have return values (it uses instead print() as output).

With cmdfunctools you can automatically create a command-line-function from any python function.

Installation

The source code can be downloaded from GitHub, where the code is always available.

It can also be installed from PyPI running:

$ pip install cmdfunctools

Usage

To create a command-line-function use the comand_func decorator:

from cmdfunctools import command_func

@command_func(itype='int', otype='int')
def add(a, b)
    res = a + b
    return res

Now the function can be referenced as is in entry_points inside setup.py and, after the package installation, it can be used from the command line interface:

$ add 3 2
5

The original function can still be used within python code using the __wrapped__() method:

>>> add.__wrapped__(3, 2)
5

Features

  • Automatic number of arguments check

  • Automatic argument type check

  • Optional argument length check (equal or less-or-equal)

  • Pipelines supported

  • I/O argument types supported:

    • integer

    • hexadecimal

The project is in 3-Alpha development status, new features will be added before 5-Production/Stable.

Metadata

Release files for cmdfunctools 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cmdfunctools 0.0.3
File Size Uploaded
cmdfunctools-0.0.3.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cmdfunctools 0.0.3
File Interpreter ABI Platform
cmdfunctools-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / cmdfunctools-0.0.3.tar.gz

Download URL cmdfunctools-0.0.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
546627334ce4fe596cd56b83da49905b5855c08f19f308e40bee5d6a6e6e8d09
BLAKE2b-256 checksum
How to use checksums
ebcdde474f3d7d21fe5e650164787e64b481711ba091c3c89da48576961d67c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / cmdfunctools-0.0.3-py3-none-any.whl

Download URL cmdfunctools-0.0.3-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f925e40d02bb65e8e8b38371ef6293c740e5f5964a8ce6af3ecea3f3487c0dc
BLAKE2b-256 checksum
How to use checksums
ae368c93ab5249ba53fddad1c7782bef5336180b63dea66d34be7f13b7729aad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page