Applying styles to CLI output
Project description
Output Styles
Aplicar estilos al texto de salida por CLI.
Install
pip install outputstyles
Usage/Examples
1 - Usar los diferentes tipos de mensajes y estilos implementados
Tipos de mensajes implementados:
| Message | Description |
|---|---|
error |
Admite las variantes: btn, ico, btn_ico |
warning |
Admite las variantes: btn, ico, btn_ico |
success |
Admite las variantes: btn, ico, btn_ico |
info |
Admite las variantes: btn, ico, btn_ico |
bold |
No tiene variantes. |
Usar los tipos de mensajes implementados:
from outputstyles import error, warning, info, success, bold
# Print error messages.
print(error("Error!"))
print(error("Error!", "btn"))
print(error("Error!", "ico"))
print(error("Error!", "btn_ico"))
# Print warning messages.
print(warning("Warning!"))
print(warning("Warning!", "ico"))
print(warning("Warning!", "btn"))
print(warning("Warning!", "btn_ico"))
# Print warning messages.
print(success("Success!"))
print(success("Success!", "btn"))
print(success("Success!", "ico"))
print(success("Success!", "btn_ico"))
# Print info messages.
print(info("Info!"))
print(info("Info!", "btn"))
print(info("Info!", "ico"))
print(info("Info!", "btn_ico"))
# Print text in bold style.
print(bold("Bold!"))
Resultado:
2 - Agregar otros estilos al texto
Modificadores y estilos que se le pueden aplicar al texto de salida:
| Modifiers | Foreground | Foreground light | Background | Background light |
|---|---|---|---|---|
| reset | fg_black | fg_light_black | bg_black | bg_light_black |
| bold | fg_red | fg_light_red | bg_red | bg_light_red |
| disabled | fg_green | fg_light_green | bg_green | bg_light_green |
| italic | fg_yellow | fg_light_yellow | bg_yellow | bg_light_yellow |
| underline | fg_blue | fg_light_blue | bg_blue | bg_light_blue |
| blink | fg_magenta | fg_light_magenta | bg_magenta | bg_light_magenta |
| blink2 | fg_cyan | fg_light_cyan | bg_cyan | bg_light_cyan |
| reverse | fg_white | fg_light_white | bg_white | bg_light_white |
| hidden | ||||
| strike_through |
Aplicar estilos personalizados:
from outputstyles import add_text_styles
# Styles of the text.
styles = ["fg_red", "underline"]
print(add_text_styles("Hola", styles))
Resultado:
3 - Crear nuevas funciones
Definir los datos y la funcion del nuevo tipo de mensaje:
from outputstyles import apply_styles
# Data of the new message.
msg_data = {
"ico_code": "\u2726",
"color": "cyan"
}
# Apply the style of the new message type.
def new_msg(text: str, msg_format: str = "", message_data: dict = msg_data) -> str:
return apply_styles(text, msg_format, message_data)
print(new_msg("Nuevo estilo"))
print(new_msg("Nuevo estilo", "btn"))
print(new_msg("Nuevo estilo", "ico"))
print(new_msg("Nuevo estilo", "btn_ico"))
Resultado:
Screenshots
License
Authors
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file outputstyles-1.0.0.tar.gz.
File metadata
- Download URL: outputstyles-1.0.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b03303f1fa2bbb079f55637032cdf58f9c56db0fc8f1792e43346694792dce6
|
|
| MD5 |
e294019a401d43545a4ef8f8bbbb3176
|
|
| BLAKE2b-256 |
e7e0da3e26f881685128b5a4a4111cb01b46b3afa00a5912e15d0153736b2555
|
File details
Details for the file outputstyles-1.0.0-py3-none-any.whl.
File metadata
- Download URL: outputstyles-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab877206ad0172529251ef5fae241068e683d16723a898a59ca6f67e0539ba3d
|
|
| MD5 |
b7de9221e374a1db3fcbae2a0e25ae8c
|
|
| BLAKE2b-256 |
3929d3ed34878515235c003a093aa32fbde516fb82377bea8187a2e44cd45b7e
|