Skip to main content

ANSI escape code formatter

Project description

afmt

This module provides an easy way to format text in CLI environment. It is designed for use in f-strings but regular string formatting with format method is also supported.

The module takes care of stripping ANSI escape sequences from piped output and puts the sequences only if they're supported by the output device.

Setup

$ pip install afmt

Usage and examples

from afmt import Formatter

f = Formatter()
warning = 'bold bg(yellow) fg(black) italic'
error = 'bold bg(red) fg(white) underline'
print(f'{f:{warning}}Warning: you shouldn\'t do it{f:e}')
print(f'{f:{error}}Error: you can\'t do it{f:e}')


# Move cursor to 4th row and 6th column and print text in reverse video mode 
print(f'{f:reverse goto(4,6)}hello, world{f:e}')

asciicast

Development status

This module is in the early stage of development. More features are coming hopefully soon.

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

afmt-0.0.3.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

afmt-0.0.3-py3-none-any.whl (4.9 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