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.3.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

clifunction-0.2.3-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

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