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.1.0.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for cli_formatter-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 272edd4e2391e7316db899f89447e99254eea40de9a0187453f14635fcb43edf |
|
MD5 | 52dc78d3e9f81ad70c8b769a3b2e1614 |
|
BLAKE2b-256 | 7656c8a182cb35c8159687ebb0a61f7b01c825357ac84f85479a4af786fc2f64 |