An utility for cli script to prettify their output
Project description
cli-formatter
cli-formatter is a python3 utility for formatting console output for cli scripts.
Current Features
- Colored output
- Ability to control the verbosity level
- Two table factories for ASCII tables
Installation
Install the package with pip
pip3 install cli-formatter
Examples
Example 1
from cli_formatter.output_formatting import info, warning, set_verbosity_level
set_verbosity_level(level=3)
info(message='This is a Info message')
info(message='This is a Info message with very low verbosity level', verbosity_level=1)
warning(message='This is a warning')
[+] This is a Info message
[!] This is a warning
Example 2
from cli_formatter.table_builder import TableBuilderClassic, TableBuilderAlternative
header=['Column 1', 'Column 2', 'Column 3']
data=[
['This is a test', '123', 'abc'],
['cli-formatter', 'is', 'awesome']
]
print('classic design:')
classic_builder = TableBuilderClassic()
classic_builder.build_table(header=header, data=data)
print('\nalterative design:')
alternative_builder = TableBuilderAlternative()
alternative_builder.build_table(header=header, data=data)
classic design:
+----------------+----------+----------+
| Column 1 | Column 2 | Column 3 |
+----------------+----------+----------+
| This is a test | 123 | abc |
| cli-formatter | is | awesome |
+----------------+----------+----------+
alterative design:
Column 1 | Column 2 | Column 3
--------------------------------------
This is a test | 123 | abc
cli-formatter | is | awesome
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cli-formatter-1.2.0.tar.gz
(4.5 kB
view details)
Built Distribution
File details
Details for the file cli-formatter-1.2.0.tar.gz
.
File metadata
- Download URL: cli-formatter-1.2.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5698b64740c72fda2ec6c12d732271fab78c8c8b65bed8a17db33125b1027da9 |
|
MD5 | f4f9a2f4d2f459e7d19f91c8a249f1f3 |
|
BLAKE2b-256 | b772112d6e1961d039c15ce2c4cfe56c4f9fcdb2095e7e455094caca7c748d05 |
File details
Details for the file cli_formatter-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: cli_formatter-1.2.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84c253f7997ec7c4fc4c1de36cc9c7e33e0ea5af342bc824dea2b5edfac60952 |
|
MD5 | dd96f2ed8bcc8df4041c70c6b6f6750a |
|
BLAKE2b-256 | 38adf8823398add76eef32fb037ed4185bec3d76a48b2f88927d84083f62ab29 |