# Path: phial/utils.py
# def parse_help_text(help_text: str) -> str:
#     """Parse help text."""
#     NEW_LINE_SEPERATOR = "<__NEW_LINE_SEPERATOR__>"
# 
#     # Strip excess whitespace
#     help_text = help_text.strip()
# 
#     # Remove single new lines
#     help_text = help_text.replace("\n", NEW_LINE_SEPERATOR)
#     help_text = help_text.replace(NEW_LINE_SEPERATOR * 2, "\n")
#     help_text = help_text.replace(NEW_LINE_SEPERATOR, "")
# 
#     # Remove extra spaces
#     help_text = re.sub(r"(^[ \t]+|[ \t]+)", " ", help_text, flags=re.M)
# 
#     return help_text


from typing import TYPE_CHECKING, cast
from phial.utils import parse_help_text
    from phial import Phial
"""Standard commands provided by phial."""


if TYPE_CHECKING:  # pragma: no cover
else:
    Phial = None


def help_command(bot: Phial) -> str:
    """List all available commands."""
    help_text = cast(str, bot.config.get("baseHelpText", ""))
    if help_text:
        help_text += "\n"
    for command in bot.commands:
        if command.hide_from_help_command:
            continue
        command_doc = command.help_text
        if not command_doc:
            # If no help text default to blank string
            command_doc = ""

# Path: phial/utils.py
# def parse_help_text(help_text: str) -> str:
#     """Parse help text."""
#     NEW_LINE_SEPERATOR = "<__NEW_LINE_SEPERATOR__>"
# 
#     # Strip excess whitespace
#     help_text = help_text.strip()
# 
#     # Remove single new lines
#     help_text = help_text.replace("\n", NEW_LINE_SEPERATOR)
#     help_text = help_text.replace(NEW_LINE_SEPERATOR * 2, "\n")
#     help_text = help_text.replace(NEW_LINE_SEPERATOR, "")
# 
#     # Remove extra spaces
#     help_text = re.sub(r"(^[ \t]+|[ \t]+)", " ", help_text, flags=re.M)
# 
#     return help_text


# Path: phial/commands.py
from typing import TYPE_CHECKING, cast
from phial.utils import parse_help_text
    from phial import Phial

"""Standard commands provided by phial."""


if TYPE_CHECKING:  # pragma: no cover
else:
    Phial = None


def help_command(bot: Phial) -> str:
    """List all available commands."""
    help_text = cast(str, bot.config.get("baseHelpText", ""))
    if help_text:
        help_text += "\n"
    for command in bot.commands:
        if command.hide_from_help_command:
            continue
        command_doc = command.help_text
        if not command_doc:
            # If no help text default to blank string
            command_doc = ""

        command_help_text = parse_help_text(command_doc)