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.4.tar.gz
(5.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02ce6c3c0eedbf23e16f6360820706099c8a8564f4f13b57dba5d85c53436fa7
|
|
| MD5 |
6262a125d96a0045525c7271b2d210f8
|
|
| BLAKE2b-256 |
f3dfacc78b0086b19de1576b0281e6aa0c07852d1f1dbce77e11f4cb683079ce
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f619e299f766953a2dc42440c9aeb3f7acec5b53997d73ee2487e240ac0246e
|
|
| MD5 |
ae3a6ae005d3adf5287c4a99e1ec0f20
|
|
| BLAKE2b-256 |
810ad427a524a9838c50e5f382bf7ca5fcf6adf1012c4c9894fedd4332046d0e
|