# Path: src/click/_compat.py
# def get_text_stderr(
#     encoding: t.Optional[str] = None, errors: t.Optional[str] = None
# ) -> t.TextIO:
#     rv = _get_windows_console_stream(sys.stderr, encoding, errors)
#     if rv is not None:
#         return rv
#     return _force_correct_text_writer(sys.stderr, encoding, errors, force_writable=True)
# 
# Path: src/click/utils.py
# def echo(
#     message: t.Optional[t.Any] = None,
#     file: t.Optional[t.IO[t.Any]] = None,
#     nl: bool = True,
#     err: bool = False,
#     color: t.Optional[bool] = None,
# ) -> None:
#     """Print a message and newline to stdout or a file. This should be
#     used instead of :func:`print` because it provides better support
#     for different data, files, and environments.
# 
#     Compared to :func:`print`, this does the following:
# 
#     -   Ensures that the output encoding is not misconfigured on Linux.
#     -   Supports Unicode in the Windows console.
#     -   Supports writing to binary outputs, and supports writing bytes
#         to text outputs.
#     -   Supports colors and styles on Windows.
#     -   Removes ANSI color and style codes if the output does not look
#         like an interactive terminal.
#     -   Always flushes the output.
# 
#     :param message: The string or bytes to output. Other objects are
#         converted to strings.
#     :param file: The file to write to. Defaults to ``stdout``.
#     :param err: Write to ``stderr`` instead of ``stdout``.
#     :param nl: Print a newline after the message. Enabled by default.
#     :param color: Force showing or hiding colors and other styles. By
#         default Click will remove color if the output does not look like
#         an interactive terminal.
# 
#     .. versionchanged:: 6.0
#         Support Unicode output on the Windows console. Click does not
#         modify ``sys.stdout``, so ``sys.stdout.write()`` and ``print()``
#         will still not support Unicode.
# 
#     .. versionchanged:: 4.0
#         Added the ``color`` parameter.
# 
#     .. versionadded:: 3.0
#         Added the ``err`` parameter.
# 
#     .. versionchanged:: 2.0
#         Support colors on Windows if colorama is installed.
#     """
#     if file is None:
#         if err:
#             file = _default_text_stderr()
#         else:
#             file = _default_text_stdout()
# 
#     # Convert non bytes/text into the native string type.
#     if message is not None and not isinstance(message, (str, bytes, bytearray)):
#         out: t.Optional[t.Union[str, bytes]] = str(message)
#     else:
#         out = message
# 
#     if nl:
#         out = out or ""
#         if isinstance(out, str):
#             out += "\n"
#         else:
#             out += b"\n"
# 
#     if not out:
#         file.flush()
#         return
# 
#     # If there is a message and the value looks like bytes, we manually
#     # need to find the binary stream and write the message in there.
#     # This is done separately so that most stream types will work as you
#     # would expect. Eg: you can write to StringIO for other cases.
#     if isinstance(out, (bytes, bytearray)):
#         binary_file = _find_binary_writer(file)
# 
#         if binary_file is not None:
#             file.flush()
#             binary_file.write(out)
#             binary_file.flush()
#             return
# 
#     # ANSI style code support. For no message or bytes, nothing happens.
#     # When outputting to a file instead of a terminal, strip codes.
#     else:
#         color = resolve_color_default(color)
# 
#         if should_strip_ansi(file, color):
#             out = strip_ansi(out)
#         elif WIN:
#             if auto_wrap_for_ansi is not None:
#                 file = auto_wrap_for_ansi(file)  # type: ignore
#             elif not color:
#                 out = strip_ansi(out)
# 
#     file.write(out)  # type: ignore
#     file.flush()


import os
import typing as t
from gettext import gettext as _
from gettext import ngettext
from ._compat import get_text_stderr
from .utils import echo
    from .core import Context
    from .core import Parameter
        return self.message

    def __str__(self) -> str:
        return self.message

    def show(self, file: t.Optional[t.IO] = None) -> None:
        if file is None:
            file = get_text_stderr()

        echo(_("Error: {message}").format(message=self.format_message()), file=file)


class UsageError(ClickException):
    """An internal exception that signals a usage error.  This typically
    aborts any further handling.

    :param message: the error message to display.
    :param ctx: optionally the context that caused this error.  Click will
                fill in the context automatically in some situations.
    """

    exit_code = 2

    def __init__(self, message: str, ctx: t.Optional["Context"] = None) -> None:
        super().__init__(message)
        self.ctx = ctx
        self.cmd = self.ctx.command if self.ctx else None

    def show(self, file: t.Optional[t.IO] = None) -> None:
        if file is None:

# Path: src/click/_compat.py
# def get_text_stderr(
#     encoding: t.Optional[str] = None, errors: t.Optional[str] = None
# ) -> t.TextIO:
#     rv = _get_windows_console_stream(sys.stderr, encoding, errors)
#     if rv is not None:
#         return rv
#     return _force_correct_text_writer(sys.stderr, encoding, errors, force_writable=True)
# 
# Path: src/click/utils.py
# def echo(
#     message: t.Optional[t.Any] = None,
#     file: t.Optional[t.IO[t.Any]] = None,
#     nl: bool = True,
#     err: bool = False,
#     color: t.Optional[bool] = None,
# ) -> None:
#     """Print a message and newline to stdout or a file. This should be
#     used instead of :func:`print` because it provides better support
#     for different data, files, and environments.
# 
#     Compared to :func:`print`, this does the following:
# 
#     -   Ensures that the output encoding is not misconfigured on Linux.
#     -   Supports Unicode in the Windows console.
#     -   Supports writing to binary outputs, and supports writing bytes
#         to text outputs.
#     -   Supports colors and styles on Windows.
#     -   Removes ANSI color and style codes if the output does not look
#         like an interactive terminal.
#     -   Always flushes the output.
# 
#     :param message: The string or bytes to output. Other objects are
#         converted to strings.
#     :param file: The file to write to. Defaults to ``stdout``.
#     :param err: Write to ``stderr`` instead of ``stdout``.
#     :param nl: Print a newline after the message. Enabled by default.
#     :param color: Force showing or hiding colors and other styles. By
#         default Click will remove color if the output does not look like
#         an interactive terminal.
# 
#     .. versionchanged:: 6.0
#         Support Unicode output on the Windows console. Click does not
#         modify ``sys.stdout``, so ``sys.stdout.write()`` and ``print()``
#         will still not support Unicode.
# 
#     .. versionchanged:: 4.0
#         Added the ``color`` parameter.
# 
#     .. versionadded:: 3.0
#         Added the ``err`` parameter.
# 
#     .. versionchanged:: 2.0
#         Support colors on Windows if colorama is installed.
#     """
#     if file is None:
#         if err:
#             file = _default_text_stderr()
#         else:
#             file = _default_text_stdout()
# 
#     # Convert non bytes/text into the native string type.
#     if message is not None and not isinstance(message, (str, bytes, bytearray)):
#         out: t.Optional[t.Union[str, bytes]] = str(message)
#     else:
#         out = message
# 
#     if nl:
#         out = out or ""
#         if isinstance(out, str):
#             out += "\n"
#         else:
#             out += b"\n"
# 
#     if not out:
#         file.flush()
#         return
# 
#     # If there is a message and the value looks like bytes, we manually
#     # need to find the binary stream and write the message in there.
#     # This is done separately so that most stream types will work as you
#     # would expect. Eg: you can write to StringIO for other cases.
#     if isinstance(out, (bytes, bytearray)):
#         binary_file = _find_binary_writer(file)
# 
#         if binary_file is not None:
#             file.flush()
#             binary_file.write(out)
#             binary_file.flush()
#             return
# 
#     # ANSI style code support. For no message or bytes, nothing happens.
#     # When outputting to a file instead of a terminal, strip codes.
#     else:
#         color = resolve_color_default(color)
# 
#         if should_strip_ansi(file, color):
#             out = strip_ansi(out)
#         elif WIN:
#             if auto_wrap_for_ansi is not None:
#                 file = auto_wrap_for_ansi(file)  # type: ignore
#             elif not color:
#                 out = strip_ansi(out)
# 
#     file.write(out)  # type: ignore
#     file.flush()


# Path: src/click/exceptions.py
import os
import typing as t
from gettext import gettext as _
from gettext import ngettext
from ._compat import get_text_stderr
from .utils import echo
    from .core import Context
    from .core import Parameter

        return self.message

    def __str__(self) -> str:
        return self.message

    def show(self, file: t.Optional[t.IO] = None) -> None:
        if file is None:
            file = get_text_stderr()

        echo(_("Error: {message}").format(message=self.format_message()), file=file)


class UsageError(ClickException):
    """An internal exception that signals a usage error.  This typically
    aborts any further handling.

    :param message: the error message to display.
    :param ctx: optionally the context that caused this error.  Click will
                fill in the context automatically in some situations.
    """

    exit_code = 2

    def __init__(self, message: str, ctx: t.Optional["Context"] = None) -> None:
        super().__init__(message)
        self.ctx = ctx
        self.cmd = self.ctx.command if self.ctx else None

    def show(self, file: t.Optional[t.IO] = None) -> None:
        if file is None:

            file = get_text_stderr()