# 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:
```python
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:
```python
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](https://pypi.org/project/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:
```python
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: 😸
```
Raw data
{
"_id": null,
"home_page": "https://github.com/coveooss/coveo-python-oss/tree/main/coveo-styles",
"name": "coveo-styles",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Jonathan Pich\u00e9",
"author_email": "tools@coveo.com",
"download_url": "https://files.pythonhosted.org/packages/81/94/c5572f3b1e903b701f96604709185c032d84624163ed2d1a4d561dc3fd26/coveo_styles-2.1.10.tar.gz",
"platform": null,
"description": "# coveo-styles\n\nDon't let your CLI app spit out hundreds of boring lines!\n\nManage your user feedback a bit like you manage logs, and get bonus colors and emojis just because we can!\n\nThis module provides an `echo` symbol that you can use instead of `print` for convenience.\n\nIt is also completely customizable!\n\n\n## predefined themes for common actions\n\nHere's how a ci run could look like:\n\n```python\nfrom coveo_styles.styles import echo\n\necho.step(\"Launching ci operations\")\necho.normal(\"pytest\", emoji='hourglass')\necho.normal(\"black\", emoji='hourglass')\necho.noise(\"Generated test reports in .ci/\")\necho.success()\necho.warning(\"Formatting errors detected\")\necho.suggest(\"The --fix switch will automatically fix these for you and re-run the test !!smile!!\")\necho.error(\"The CI run detected errors you need to fix\", pad_after=False)\necho.error_details(\"Black reported files to reformat\", item=True)\necho.error_details(\"Details as items is nice!\", item=True)\n```\n\n\n```\nLaunching ci operations\n\n\u231b pytest\n\u231b black\nGenerated test reports in .ci/\n\n\u2714 Success!\n\n\n\u26a0 Formatting errors detected\n\n\n\ud83e\udd16 The --fix switch will automatically fix these for you and re-run the test \ud83d\ude04\n\n\n\ud83d\udca5 The CI run detected errors you need to fix\n \u0387 Black reported files to reformat\n \u0387 Details as items is nice\n```\n\nIt's even nicer with colors! :) This doc needs a few animated gifs!\n\n\n\n# exception hook\n\nException handlers may re-raise an exception as an `ExitWithFailure` in order to hide the traceback from the user and show a helpful error message.\n\nHere's an example for the sake of demonstration:\n\n```python\nfrom pathlib import Path\nfrom coveo_styles.styles import ExitWithFailure\n\ntry:\n project = Path('./project').read_text()\nexcept FileNotFoundError as exception:\n raise ExitWithFailure(suggestions='Use the --list switch to see which projects I can see') from exception\n```\n\nThe stacktrace will be hidden, the app will exit with code 1 after printing the exception type and message:\n\n```\n! FileNotFoundError: [Errno 2] No such file or directory: 'project'\n\n\ud83e\udd16 Use the --list switch to see which projects I can see\n```\n\nUnhandled exceptions (those that are not wrapped by an ExitWithFailure), will display the usual python feedback and stacktrace.\n\n\n\n# hunting for emojis\n\nEmoji support is provided by the [emoji](https://pypi.org/project/emoji/) package. \nTheir 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.\n\nThe 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:\n\n```python\nfrom coveo_styles.styles import echo\nfrom emoji.unicode_codes.en import EMOJI_UNICODE_ENGLISH, EMOJI_ALIAS_UNICODE_ENGLISH\n\nquery = 'smile'.lower()\n\nfor emoji_name in {*EMOJI_UNICODE_ENGLISH, *EMOJI_ALIAS_UNICODE_ENGLISH}:\n emoji_name = emoji_name.strip(':')\n if query in emoji_name.lower():\n echo.normal(f'{emoji_name}: !!{emoji_name}!!')\n```\n\n```\nsweat_smile: \ud83d\ude05\ncat_face_with_wry_smile: \ud83d\ude3c\nsmile: \ud83d\ude04\nsmiley: \ud83d\ude03\nsmiley_cat: \ud83d\ude3a\nsmile_cat: \ud83d\ude38\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Styles, colors and emojis for the command line.",
"version": "2.1.10",
"project_urls": {
"Homepage": "https://github.com/coveooss/coveo-python-oss/tree/main/coveo-styles",
"Repository": "https://github.com/coveooss/coveo-python-oss/tree/main/coveo-styles"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "34fb23995e37fe06e0bb82012ab2276262a90d77aed55b70e0251bd4159f5097",
"md5": "711f78cfe570f15e38320e060ac80a16",
"sha256": "fe62285597b951886931bb67f73b605232ecfdec09c140651c8dd1926f7fa409"
},
"downloads": -1,
"filename": "coveo_styles-2.1.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "711f78cfe570f15e38320e060ac80a16",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7390,
"upload_time": "2024-03-24T12:46:23",
"upload_time_iso_8601": "2024-03-24T12:46:23.643350Z",
"url": "https://files.pythonhosted.org/packages/34/fb/23995e37fe06e0bb82012ab2276262a90d77aed55b70e0251bd4159f5097/coveo_styles-2.1.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8194c5572f3b1e903b701f96604709185c032d84624163ed2d1a4d561dc3fd26",
"md5": "553175d375a342e0d4457f8a5dfae067",
"sha256": "c69ca119a0f7b8472491635f37007fe31f15c6222c02dd2948770d5368947b84"
},
"downloads": -1,
"filename": "coveo_styles-2.1.10.tar.gz",
"has_sig": false,
"md5_digest": "553175d375a342e0d4457f8a5dfae067",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6988,
"upload_time": "2024-03-24T12:46:24",
"upload_time_iso_8601": "2024-03-24T12:46:24.857034Z",
"url": "https://files.pythonhosted.org/packages/81/94/c5572f3b1e903b701f96604709185c032d84624163ed2d1a4d561dc3fd26/coveo_styles-2.1.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-24 12:46:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "coveooss",
"github_project": "coveo-python-oss",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "coveo-styles"
}