Skip to main content

Styles, colors and emojis for the command line.

Project description

coveo-styles

Don't let your CLI app spit out hundreds of boring lines!

Manage your user feedback a bit like you manage logs, and get bonus colors and emojis just because we can!

This module provides an echo symbol that you can use instead of print for convenience.

It is also completely customizable!

predefined themes for common actions

Here's how a ci run could look like:

from coveo_styles.styles import echo

echo.step("Launching ci operations")
echo.normal("pytest", emoji='hourglass')
echo.normal("black", emoji='hourglass')
echo.noise("Generated test reports in .ci/")
echo.success()
echo.warning("Formatting errors detected")
echo.suggest("The --fix switch will automatically fix these for you and re-run the test !!smile!!")
echo.error("The CI run detected errors you need to fix", pad_after=False)
echo.error_details("Black reported files to reformat", item=True)
echo.error_details("Details as items is nice!", item=True)
Launching ci operations

⌛ pytest
⌛ black
Generated test reports in .ci/

✔ Success!


⚠ Formatting errors detected


🤖 The --fix switch will automatically fix these for you and re-run the test 😄


💥 The CI run detected errors you need to fix
 · Black reported files to reformat
 · Details as items is nice

It's even nicer with colors! :) This doc needs a few animated gifs!

exception hook

Exception handlers may re-raise an exception as an ExitWithFailure in order to hide the traceback from the user and show a helpful error message.

Here's an example for the sake of demonstration:

from pathlib import Path
from coveo_styles.styles import ExitWithFailure

try:
    project = Path('./project').read_text()
except FileNotFoundError as exception:
    raise ExitWithFailure(suggestions='Use the --list switch to see which projects I can see') from exception

The stacktrace will be hidden, the app will exit with code 1 after printing the exception type and message:

! FileNotFoundError: [Errno 2] No such file or directory: 'project'

🤖 Use the --list switch to see which projects I can see

Unhandled exceptions (those that are not wrapped by an ExitWithFailure), will display the usual python feedback and stacktrace.

hunting for emojis

Emoji support is provided by the emoji package. Their description provides different links to help with your emoji hunt, but for some reason not everything is supported or has the name it should have.

The only foolproof way I have found is to actually inspect the emoji package, either by opening site-packages/emoji/unicode_codes/en.py in my IDE or programmatically like this:

from coveo_styles.styles import echo
from emoji.unicode_codes.en import EMOJI_UNICODE_ENGLISH, EMOJI_ALIAS_UNICODE_ENGLISH

query = 'smile'.lower()

for emoji_name in {*EMOJI_UNICODE_ENGLISH, *EMOJI_ALIAS_UNICODE_ENGLISH}:
    emoji_name = emoji_name.strip(':')
    if query in emoji_name.lower():
        echo.normal(f'{emoji_name}: !!{emoji_name}!!')
sweat_smile: 😅
cat_face_with_wry_smile: 😼
smile: 😄
smiley: 😃
smiley_cat: 😺
smile_cat: 😸

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

coveo_styles-2.1.10.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

coveo_styles-2.1.10-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file coveo_styles-2.1.10.tar.gz.

File metadata

  • Download URL: coveo_styles-2.1.10.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.18 Linux/5.15.0-1058-azure

File hashes

Hashes for coveo_styles-2.1.10.tar.gz
Algorithm Hash digest
SHA256 c69ca119a0f7b8472491635f37007fe31f15c6222c02dd2948770d5368947b84
MD5 553175d375a342e0d4457f8a5dfae067
BLAKE2b-256 8194c5572f3b1e903b701f96604709185c032d84624163ed2d1a4d561dc3fd26

See more details on using hashes here.

File details

Details for the file coveo_styles-2.1.10-py3-none-any.whl.

File metadata

  • Download URL: coveo_styles-2.1.10-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.18 Linux/5.15.0-1058-azure

File hashes

Hashes for coveo_styles-2.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 fe62285597b951886931bb67f73b605232ecfdec09c140651c8dd1926f7fa409
MD5 711f78cfe570f15e38320e060ac80a16
BLAKE2b-256 34fb23995e37fe06e0bb82012ab2276262a90d77aed55b70e0251bd4159f5097

See more details on using hashes here.

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