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
- 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}")
- 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
- 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
- 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)
Built Distribution
Close
Hashes for clifunction-0.2.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ec8ac9101e7934c946a826aff49c6c1528105b7969bf1d3ea60e9c4a8122cbe |
|
MD5 | 48034bd8ceac4d78bf3c08443cf3fe13 |
|
BLAKE2b-256 | 0bf0932ae4d3c6bcb91c54eb3cace6b73d5689a0abd3fb2b148ab59c41e0c81e |