eonu / feud

Build powerful CLIs with simple idiomatic Python, driven by type hints. Not all arguments are bad.

Home Page:https://feud.wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Define `feud.click.is_rich` to check if `rich_click` is installed

eonu opened this issue · comments

Does this suggestion already exist?

  • This is a new feature!

Feature description

There is currently no easy way to check whether rich_click is installed and being used.

A simple way to do this is to change:

try:
from rich_click import *
except ImportError:
from click import *

To:

#: Whether ``rich_click`` is installed or not.
is_rich: bool

try: 
    from rich_click import * 
    is_rich = True
except ImportError: 
    from click import * 
    is_rich = False

Then feud.click.is_rich can be used within the code base or by the user.

Existing parts of the code base relying on similar checks should be updated to re-use this variable.