def METHOD_NAME(self, ctx, opts, args):
    opt_name = self.hook_name_option_name.replace("_", "-")
    if (
        self.hook_name_option_name not in opts
        and self.hook_name_option_name not in ctx.default_map
        or self.help_option_name in opts
        or self.help_option_name in ctx.default_map
    ):
        return super().METHOD_NAME(ctx, opts, args)
    command_name = ctx.command.name
    if command_name in ["invoke", "start-lambda", "start-api"]:
        command_name = f"local {command_name}"
    # validate the hook_name value exists
    hook_name = opts.get(self.hook_name_option_name) or ctx.default_map[self.hook_name_option_name]
    iac_hook_wrapper = None
    try:
        iac_hook_wrapper = IacHookWrapper(hook_name)
    except InvalidHookWrapperException as e:
        raise click.BadParameter(
            f"{hook_name} is not a valid hook name."
            f"{os.linesep}valid package ids: {get_available_hook_packages_ids()}"
        ) from e
    self._validate_coexist_options(opt_name, opts)
    _validate_build_command_parameters(command_name, opts)
    try:
        self._call_prepare_hook(iac_hook_wrapper, opts, ctx)
    except Exception as ex:
        # capture exceptions from prepare hook to emit in track_command
        c = Context.get_current_context()
        c.exception = ex
    finally:
        record_hook_telemetry(opts, ctx)
    return super().METHOD_NAME(ctx, opts, args)