# Path: src/click/exceptions.py
# class BadArgumentUsage(UsageError):
#     """Raised if an argument is generally supplied but the use of the argument
#     was incorrect.  This is for instance raised if the number of values
#     for an argument is not correct.
# 
#     .. versionadded:: 6.0
#     """
# 
# Path: src/click/exceptions.py
# class BadOptionUsage(UsageError):
#     """Raised if an option is generally supplied but the use of the option
#     was incorrect.  This is for instance raised if the number of arguments
#     for an option is not correct.
# 
#     .. versionadded:: 4.0
# 
#     :param option_name: the name of the option being used incorrectly.
#     """
# 
#     def __init__(
#         self, option_name: str, message: str, ctx: t.Optional["Context"] = None
#     ) -> None:
#         super().__init__(message, ctx)
#         self.option_name = option_name
# 
# Path: src/click/exceptions.py
# class NoSuchOption(UsageError):
#     """Raised if click attempted to handle an option that does not
#     exist.
# 
#     .. versionadded:: 4.0
#     """
# 
#     def __init__(
#         self,
#         option_name: str,
#         message: t.Optional[str] = None,
#         possibilities: t.Optional[t.Sequence[str]] = None,
#         ctx: t.Optional["Context"] = None,
#     ) -> None:
#         if message is None:
#             message = _("No such option: {name}").format(name=option_name)
# 
#         super().__init__(message, ctx)
#         self.option_name = option_name
#         self.possibilities = possibilities
# 
#     def format_message(self) -> str:
#         if not self.possibilities:
#             return self.message
# 
#         possibility_str = ", ".join(sorted(self.possibilities))
#         suggest = ngettext(
#             "Did you mean {possibility}?",
#             "(Possible options: {possibilities})",
#             len(self.possibilities),
#         ).format(possibility=possibility_str, possibilities=possibility_str)
#         return f"{self.message} {suggest}"
# 
# Path: src/click/exceptions.py
# 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()
#         color = None
#         hint = ""
#         if (
#             self.ctx is not None
#             and self.ctx.command.get_help_option(self.ctx) is not None
#         ):
#             hint = _("Try '{command} {option}' for help.").format(
#                 command=self.ctx.command_path, option=self.ctx.help_option_names[0]
#             )
#             hint = f"{hint}\n"
#         if self.ctx is not None:
#             color = self.ctx.color
#             echo(f"{self.ctx.get_usage()}\n{hint}", file=file, color=color)
#         echo(
#             _("Error: {message}").format(message=self.format_message()),
#             file=file,
#             color=color,
#         )


import typing as t
    import typing_extensions as te
    import shlex
from collections import deque
from gettext import gettext as _
from gettext import ngettext
from .exceptions import BadArgumentUsage
from .exceptions import BadOptionUsage
from .exceptions import NoSuchOption
from .exceptions import UsageError
    from .core import Argument as CoreArgument
    from .core import Context
    from .core import Option as CoreOption
    from .core import Parameter as CoreParameter
            from difflib import get_close_matches
            if explicit_value is not None:
                state.rargs.insert(0, explicit_value)

            value = self._get_value_from_state(opt, option, state)

        elif explicit_value is not None:
            raise BadOptionUsage(
                opt, _("Option {name!r} does not take a value.").format(name=opt)
            )

        else:
            value = None

        option.process(value, state)

    def _match_short_opt(self, arg: str, state: ParsingState) -> None:
        stop = False
        i = 1
        prefix = arg[0]
        unknown_options = []

        for ch in arg[1:]:
            opt = normalize_opt(f"{prefix}{ch}", self.ctx)
            option = self._short_opt.get(opt)
            i += 1

            if not option:
                if self.ignore_unknown_options:
                    unknown_options.append(ch)
                    continue

# Path: src/click/exceptions.py
# class BadArgumentUsage(UsageError):
#     """Raised if an argument is generally supplied but the use of the argument
#     was incorrect.  This is for instance raised if the number of values
#     for an argument is not correct.
# 
#     .. versionadded:: 6.0
#     """
# 
# Path: src/click/exceptions.py
# class BadOptionUsage(UsageError):
#     """Raised if an option is generally supplied but the use of the option
#     was incorrect.  This is for instance raised if the number of arguments
#     for an option is not correct.
# 
#     .. versionadded:: 4.0
# 
#     :param option_name: the name of the option being used incorrectly.
#     """
# 
#     def __init__(
#         self, option_name: str, message: str, ctx: t.Optional["Context"] = None
#     ) -> None:
#         super().__init__(message, ctx)
#         self.option_name = option_name
# 
# Path: src/click/exceptions.py
# class NoSuchOption(UsageError):
#     """Raised if click attempted to handle an option that does not
#     exist.
# 
#     .. versionadded:: 4.0
#     """
# 
#     def __init__(
#         self,
#         option_name: str,
#         message: t.Optional[str] = None,
#         possibilities: t.Optional[t.Sequence[str]] = None,
#         ctx: t.Optional["Context"] = None,
#     ) -> None:
#         if message is None:
#             message = _("No such option: {name}").format(name=option_name)
# 
#         super().__init__(message, ctx)
#         self.option_name = option_name
#         self.possibilities = possibilities
# 
#     def format_message(self) -> str:
#         if not self.possibilities:
#             return self.message
# 
#         possibility_str = ", ".join(sorted(self.possibilities))
#         suggest = ngettext(
#             "Did you mean {possibility}?",
#             "(Possible options: {possibilities})",
#             len(self.possibilities),
#         ).format(possibility=possibility_str, possibilities=possibility_str)
#         return f"{self.message} {suggest}"
# 
# Path: src/click/exceptions.py
# 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()
#         color = None
#         hint = ""
#         if (
#             self.ctx is not None
#             and self.ctx.command.get_help_option(self.ctx) is not None
#         ):
#             hint = _("Try '{command} {option}' for help.").format(
#                 command=self.ctx.command_path, option=self.ctx.help_option_names[0]
#             )
#             hint = f"{hint}\n"
#         if self.ctx is not None:
#             color = self.ctx.color
#             echo(f"{self.ctx.get_usage()}\n{hint}", file=file, color=color)
#         echo(
#             _("Error: {message}").format(message=self.format_message()),
#             file=file,
#             color=color,
#         )


# Path: src/click/parser.py
import typing as t
    import typing_extensions as te
    import shlex
from collections import deque
from gettext import gettext as _
from gettext import ngettext
from .exceptions import BadArgumentUsage
from .exceptions import BadOptionUsage
from .exceptions import NoSuchOption
from .exceptions import UsageError
    from .core import Argument as CoreArgument
    from .core import Context
    from .core import Option as CoreOption
    from .core import Parameter as CoreParameter
            from difflib import get_close_matches

            if explicit_value is not None:
                state.rargs.insert(0, explicit_value)

            value = self._get_value_from_state(opt, option, state)

        elif explicit_value is not None:
            raise BadOptionUsage(
                opt, _("Option {name!r} does not take a value.").format(name=opt)
            )

        else:
            value = None

        option.process(value, state)

    def _match_short_opt(self, arg: str, state: ParsingState) -> None:
        stop = False
        i = 1
        prefix = arg[0]
        unknown_options = []

        for ch in arg[1:]:
            opt = normalize_opt(f"{prefix}{ch}", self.ctx)
            option = self._short_opt.get(opt)
            i += 1

            if not option:
                if self.ignore_unknown_options:
                    unknown_options.append(ch)
                    continue

                raise NoSuchOption(opt, ctx=self.ctx)