Skip to main content

Build a fully featured CLI for your python project with minium effort

Project description

clifunction

Introduction

clifunction makes building and maintaining command line utilities easier than ever by using the annotations included in modern python versions, Here is a quick look:

How your code looks:

@cli_function
def migrate_data_base(*, start_version: int = 0, end_version: int = 3):
    """
    Runs DB migrations.
    """
    print(f"Migrating DB from {start_version} to {end_version}")

How you invoke that function:

isaak@laptop:/mnt/c/Users/isaak/dev/clifunction$ python3 Example.py migrate_data_base
migrate_data_base:  {}
Migrating DB from 0 to 3

Getting Started

  1. Fully annotate a python function you want to call externally, and add the cli_function decorator:
@cli_function
def migrate_data_base(*, start_version: int = 0, end_version: int = 3):
    """
    Runs DB migrations.
    """
    print(f"Migrating DB from {start_version} to {end_version}")
  1. Call your function from the command line:
isaak@laptop:/mnt/c/Users/isaak/dev/clifunction$ python3 Example.py migrate_data_base
migrate_data_base:  {}
Migrating DB from 0 to 3
  1. Call your functions by auto-generated alias's, and handle Pythons built-in types:
isaak@laptop:/mnt/c/Users/isaak/dev/clifunction$ python3 Example.py mdb -sv=4 --end_version=5
migrate_data_base:  {'start_version': 4, 'end_version': 5}
Migrating DB from 4 to 5
  1. Documentation, Error handling, and Man pages are all automatically generated:
isaak@laptop:/mnt/c/Users/isaak/dev/clifunction$ python3 Example.py
Example.py
        deploy -- builds*, tests*, and then deploys the project
                build_first | default:True | type:<class 'bool'>
                test_first | default:True | type:<class 'bool'>
                
        build -- Bundles python project for distribution

        test -- Execs out to PyTest to run the test suite

        migrate_data_base -- Runs DB migrations
                start_version | default:0 | type:<class 'int'>
                end_version | default:3 | type:<class 'int'>

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

clifunction-0.2.4.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

clifunction-0.2.4-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file clifunction-0.2.4.tar.gz.

File metadata

  • Download URL: clifunction-0.2.4.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for clifunction-0.2.4.tar.gz
Algorithm Hash digest
SHA256 02ce6c3c0eedbf23e16f6360820706099c8a8564f4f13b57dba5d85c53436fa7
MD5 6262a125d96a0045525c7271b2d210f8
BLAKE2b-256 f3dfacc78b0086b19de1576b0281e6aa0c07852d1f1dbce77e11f4cb683079ce

See more details on using hashes here.

File details

Details for the file clifunction-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: clifunction-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for clifunction-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0f619e299f766953a2dc42440c9aeb3f7acec5b53997d73ee2487e240ac0246e
MD5 ae3a6ae005d3adf5287c4a99e1ec0f20
BLAKE2b-256 810ad427a524a9838c50e5f382bf7ca5fcf6adf1012c4c9894fedd4332046d0e

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