Have pretty cli output without hassle
https://pypi.org/project/cliasi
- Python 97%
- Makefile 3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
* test no longer runs on tags * remove old docs.yml workflow (moved to readthedocs.io) * remove default comments |
||
| .github/workflows | ||
| docs | ||
| examples | ||
| src/cliasi | ||
| tests | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| .readthedocs.yaml | ||
| LICENSE | ||
| Makefile | ||
| pyproject.toml | ||
| README.md | ||
| uv.lock | ||
cliasi (cli easy)
Output pretty command line text without hassle.
This is mostly a collection of pretty print commands
View the documentation here.
Installation
pip install cliasi
uv add cliasi
Basic Usage
from cliasi import cli
cli.success("It works!")
# > ✔ [CLI] | It works!
cli.messages_stay_in_one_line = True
# The next few lines will get overwritten
cli.info("blah")
cli.warn("doing something dangerous")
# > ! [CLI] | doing something dangerous
Read more about different message types and see visualizations in the documentation here.
Animations
One of the main features of cliasi is the ability to display animations while waiting for something to finish.
# File: examples/readme_demo.py
from cliasi import cli
# This will wait for three seconds and display an animation
task = cli.animate_message_non_blocking(
"Saving files...",
message_right="[CTRL-C to abort]",
messages_stay_in_one_line=True
)
do_stuff()
task.update("Files saved, waiting for process to quit", message_right="70%")
tell_process_to_quit()
task.stop()
cli.success("Process quit", message_right="100%")
Catching exceptions
cliasi also catches exceptions and displays them in a pretty way. This then looks something like this:
# exception_message.py
import cliasi
# Importing cliasi automatically installs the logging handler
raise ValueError("An example error")
Example CLI output (uncolored, see colored version in docs):
X [CLI] | Uncaught exception:
X [CLI] | Traceback (most recent call last):
| File "examples/exception_message.py", line 4, in <module>
| raise ValueError("An example error")
| ValueError: An example error
Other features
cliasi has many more features like:
- Logging integration
- Custom message alignments
- Customizable progressbars (with
PBCalculationMode) - And more!
Contributing:
This is just a fun project of mine mainly to try out python packaging. If you would like to contribute or have a feature-request, please open an issue or pull request.
