auto-cli-py
Python Library that builds a complete CLI given one or more functions.
Most options are set using introspection/signature and annotation functionality, so very little configuration has to be done.
Setup
TL;DR Install for usage
# Install from github
pip install auto-cli-py
# See example code and output
python examples.py
In python code
Development
- Standard python packaging - Follows methodologies from: https://python-packaging.readthedocs.io/en/latest/minimal .html
- Uses pytest
Pytest
https://docs.pytest.org/en/latest/
Python (Anaconda) environment
(assumes anaconda is properly installed)
# First time. Create conda environment from environment.yml and activate it:
conda env create -f environment.yml -n auto-cli-py
conda activate auto-cli-py
# If environment changes:
conda activate auto-cli-py
conda env update -f=environment.yml
# -- OR remove and restart --
conda remove --name auto-cli-py --all
conda env create -f environment.yml
Activate environment
conda activate auto-cli-py
# This symlinks the installed auto_cli package to the source:
pip install -e .
Preparation
conda activate auto-cli-py
Linting and Testing
pytest behavior and output is controlled through auto_cli/tests/pytest.ini
# Lint all code:
pylint auto_cli
# Run all tests
pytest
# See more options for pytest:
pytest --help
# This is handy:
pytest --fixtures-per-test
Installation (other)
# AND/OR Install from a specific github branch
pip uninstall auto-cli-py
pip install git+https://github.com/tangledpath/auto-cli-py.git@features/blah
---## Example
#!/usr/bin/env python
"""
Simple Examples of CLI creation.
"""
import sys
from auto_cli.cli import CLI
import enum
def foo():
print("FOO!")
def train(
data_dir:str='./data/',
initial_learning_rate:float=0.0001,
seed:int=2112,
batch_size:int=512,
epochs:int = 20):
print("Training with initial_learning_rate:{initial_learning_rate}, seed:{seed}, batch_size:{batch_size}, epochs:{epochs} into data_dir:{data_dir}")
#AnimalEnum = enum.Enum('Animal', 'ANT BEE CAT DOG')
class AnimalEnum(enum.Enum):
ANT = 1
BEE = 2
CAT = 3
DOG = 4
def count_animals(count:int=20, animal:AnimalEnum=AnimalEnum.BEE):
return count
if __name__ == '__main__':
fn_opts = {
'foo': {'description':'Foobar'},
'train': {'description':'Train'},
'count_animals': {'description':'Count Animals'},
}
cli = CLI(sys.modules[__name__], function_opts=fn_opts, title="Foobar Example CLI")
cli.display()
`
`
`
Metadata
Release files for auto-cli-py 0.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| auto-cli-py-0.4.6.tar.gz | 5.5 kB | Without provenance | Details for auto-cli-py-0.4.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| auto_cli_py-0.4.6-py3-none-any.whl | Python 3 | none | any | Details for auto_cli_py-0.4.6-py3-none-any.whl |
Total release size: 11.7 kB
Release files / auto-cli-py-0.4.6.tar.gz
| Download URL | auto-cli-py-0.4.6.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f130b9cc2e673e44063de5cdec6606a01afbfe5f06f87084a42a7a4f9b1f723
|
|
BLAKE2b-256 checksum How to use checksums |
ce35f9a0968669dca46252232599fee0253564c9bd53c8778b550852cd717ba5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2
|
Release files / auto_cli_py-0.4.6-py3-none-any.whl
| Download URL | auto_cli_py-0.4.6-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8791e019bd8cdf09c5906a10a278626cb65dda1f79b5bdbd867e598dc5c0013c
|
|
BLAKE2b-256 checksum How to use checksums |
cb360fe0eb27a89c2b6d6339db9cc56e245da59d47818e513e0ee7f61fbcabb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2
|
Security for auto-cli-py 0.4.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.