Skip to main content

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


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 hashes)

Uploaded Source

Built Distribution

cli_formatter-1.2.0-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page