Async Cmd2
Async extension to a famous Cmd2 library.
Cmd2 permanently occupies the main thread which is a problem if you plan to receive callbacks on the main thread (e.g., by Bluetooth stack Bleak)
Pip installation
BoolTest is available via pip:
pip3 install ph4-acmd2
Local installation
From the local dir:
pip3 install --upgrade --find-links=. .
Usage
import asyncio
import ph4acmd2
class CmdLineApp(ph4acmd2.Cmd):
async def main(self):
await self.acmdloop()
print("Cmdloop finished now")
if __name__ == '__main__':
app = CmdLineApp()
loop = asyncio.get_event_loop()
loop.set_debug(True)
loop.run_until_complete(app.main())
Limitations
We use asyncio.lool.add_reader to read from the stdin and process the commands thus it is not currently possible to ue readline features such as auto-complete or ctrl-r, UP-arrow for previous commands, etc…
Readline occupies main thread in a blocking way, so it is not compatible with runloop model running on the main thread and executing coroutines.
In order to use readline it needs to add async support. A potential workaround could be to access terminal in async way e.g., submit short coroutine monitoring the terminal state to simulate readline library. However, it is not tested.
Development
Install pre-commit hooks defined by .pre-commit-config.yaml
pip3 install -U pre-commit pytest mypy
mypy --install-types
pre-commit install
Auto fix
pre-commit run --all-files
Plugin version update
pre-commit autoupdate
Metadata
Release files for ph4-acmd2 1.0.0
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 |
|---|---|---|---|---|
| ph4_acmd2-1.0.0.tar.gz | 6.0 kB | Without provenance | Details for ph4_acmd2-1.0.0.tar.gz |
Release files / ph4_acmd2-1.0.0.tar.gz
| Download URL | ph4_acmd2-1.0.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
313b8d63e0887dbce678e6b3271f890ca3c5c8f7bd3b0341bc07ace42b1bcca5
|
|
BLAKE2b-256 checksum How to use checksums |
5210dbfc94609aec99794914808c3b3e46fbb76fb31eaef21dd2e2d3e6555b6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for ph4-acmd2 1.0.0
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.