# Path: awscfncli2/cli/context.py
# class Context:
#     """Click context object
# 
# 
#     # Manage config parsing, transforming deployment process.
#     """
# 
#     def __init__(self,
#                  config_filename: str,
#                  artifact_store: str,
#                  pretty_printer: StackPrettyPrinter,
#                  stack_selector: StackSelector,
#                  boto3_profile: Boto3Profile,
#                  builder,
#                  ):
#         # simple
#         self._config_filename: str = config_filename
#         self._artifact_store: str = artifact_store
#         # complex
#         self._pretty_printer: StackPrettyPrinter = pretty_printer
#         self._stack_selector = stack_selector
#         self._boto3_profile = boto3_profile
#         # lazy-loaded
#         self._deployments = None
#         self._command_runner = None
# 
#         # internals
#         self.__builder = builder
#         self.__lock = threading.RLock()
# 
#     @property
#     def config_filename(self):
#         """Config file name"""
#         return self._config_filename
# 
#     @property
#     def stack_selector(self):
#         """Stack selector"""
#         return self._stack_selector
# 
#     @property
#     def boto3_profile(self):
#         """Boto3 session profiles"""
#         return self._boto3_profile
# 
#     @property
#     def verbosity(self):
#         """Verbosity level"""
#         return self._pretty_printer.verbosity
# 
#     @property
#     def ppt(self):
#         """CLI pretty printer"""
#         return self._pretty_printer
# 
#     @property
#     def deployments(self):
#         """Stack deployment spec."""
#         # XXX: Lazy-loading so we don't get error if user is just looking at help
#         with self.__lock:
#             if self._deployments is None:
#                 self._deployments = self.__builder.parse_config(self.config_filename)
#         return self._deployments
# 
#     @property
#     def runner(self):
#         """Command runner."""
#         with self.__lock:
#             if self._command_runner is None:
#                 self._command_runner = self.__builder.build_runner(
#                     self.boto3_profile,
#                     self._artifact_store,
#                     self.deployments,
#                     self.stack_selector,
#                     self.ppt
#                 )
#         return self._command_runner
# 
# Path: awscfncli2/cli/utils/deco.py
# def command_exception_handler(f):
#     """Capture and pretty print exceptions."""
# 
#     @wraps(f)
#     def wrapper(ctx, *args, **kwargs):
#         try:
#             return f(ctx, *args, **kwargs)
#         except (botocore.exceptions.ClientError,
#                 botocore.exceptions.BotoCoreError,
#                 ) as e:
#             if ctx.obj.verbosity > 0:
#                 click.secho(traceback.format_exc(), fg='red')
#             else:
#                 click.secho(str(e), fg='red')
#             raise click.Abort
#         except ConfigError as e:
#             click.secho(str(e), fg='red')
#             if ctx.obj.verbosity > 0:
#                 traceback.print_exc()
#             raise click.Abort
# 
#     return wrapper
# 
# Path: awscfncli2/runner/commands/stack_delete_command.py
# class StackDeleteOptions(namedtuple('StackDeleteOptions',
#                                     ['no_wait',
#                                      'ignore_missing'])):
#     pass
# 
# class StackDeleteCommand(Command):
#     SKIP_UPDATE_REFERENCES = True
# 
#     def run(self, stack_context):
#         # stack contexts
#         session = stack_context.session
#         parameters = stack_context.parameters
#         metadata = stack_context.metadata
# 
#         self.ppt.pprint_stack_name(stack_context.stack_key,
#                                    parameters['StackName'],
#                                    'Deleting stack ')
# 
#         # create boto3 cfn resource
#         cfn = session.resource('cloudformation')
#         self.ppt.pprint_session(session)
#         self.ppt.pprint_parameters(parameters)
# 
#         # call boto3
#         stack = cfn.Stack(parameters['StackName'])
#         try:
#             update_termination_protection(
#                 session,
#                 parameters.pop('EnableTerminationProtection', None),
#                 parameters['StackName'],
#                 self.ppt)
#             self.ppt.pprint_stack(stack)
#             stack.delete()
#         except Exception as ex:
#             if self.options.ignore_missing and \
#                     is_stack_does_not_exist_exception(ex):
#                 self.ppt.secho(str(ex), fg='red')
#                 return
#             else:
#                 raise
# 
#         # wait until delete complete
#         if self.options.no_wait:
#             self.ppt.secho('Stack is being deleted.')
#         else:
#             self.ppt.wait_until_delete_complete(session, stack)
#             self.ppt.secho('Stack delete complete.', fg='green')


import click
from awscfncli2.cli.context import Context
from awscfncli2.cli.utils.deco import command_exception_handler
from awscfncli2.runner.commands.stack_delete_command import StackDeleteOptions, \
    StackDeleteCommand
#  -*- encoding: utf-8 -*-




@click.command()
@click.option('--quiet', '-q', is_flag=True, default=False,
              help='Suppress warning if more than one stack is being deleted.')
@click.option('--no-wait', '-w', is_flag=True, default=False,
              help='Exit immediately after delete is started.')
@click.option('--ignore-missing', '-i', is_flag=True, default=False,
              help='Don\'t exit with error if the stack is missing.')
@click.pass_context

# Path: awscfncli2/cli/context.py
# class Context:
#     """Click context object
# 
# 
#     # Manage config parsing, transforming deployment process.
#     """
# 
#     def __init__(self,
#                  config_filename: str,
#                  artifact_store: str,
#                  pretty_printer: StackPrettyPrinter,
#                  stack_selector: StackSelector,
#                  boto3_profile: Boto3Profile,
#                  builder,
#                  ):
#         # simple
#         self._config_filename: str = config_filename
#         self._artifact_store: str = artifact_store
#         # complex
#         self._pretty_printer: StackPrettyPrinter = pretty_printer
#         self._stack_selector = stack_selector
#         self._boto3_profile = boto3_profile
#         # lazy-loaded
#         self._deployments = None
#         self._command_runner = None
# 
#         # internals
#         self.__builder = builder
#         self.__lock = threading.RLock()
# 
#     @property
#     def config_filename(self):
#         """Config file name"""
#         return self._config_filename
# 
#     @property
#     def stack_selector(self):
#         """Stack selector"""
#         return self._stack_selector
# 
#     @property
#     def boto3_profile(self):
#         """Boto3 session profiles"""
#         return self._boto3_profile
# 
#     @property
#     def verbosity(self):
#         """Verbosity level"""
#         return self._pretty_printer.verbosity
# 
#     @property
#     def ppt(self):
#         """CLI pretty printer"""
#         return self._pretty_printer
# 
#     @property
#     def deployments(self):
#         """Stack deployment spec."""
#         # XXX: Lazy-loading so we don't get error if user is just looking at help
#         with self.__lock:
#             if self._deployments is None:
#                 self._deployments = self.__builder.parse_config(self.config_filename)
#         return self._deployments
# 
#     @property
#     def runner(self):
#         """Command runner."""
#         with self.__lock:
#             if self._command_runner is None:
#                 self._command_runner = self.__builder.build_runner(
#                     self.boto3_profile,
#                     self._artifact_store,
#                     self.deployments,
#                     self.stack_selector,
#                     self.ppt
#                 )
#         return self._command_runner
# 
# Path: awscfncli2/cli/utils/deco.py
# def command_exception_handler(f):
#     """Capture and pretty print exceptions."""
# 
#     @wraps(f)
#     def wrapper(ctx, *args, **kwargs):
#         try:
#             return f(ctx, *args, **kwargs)
#         except (botocore.exceptions.ClientError,
#                 botocore.exceptions.BotoCoreError,
#                 ) as e:
#             if ctx.obj.verbosity > 0:
#                 click.secho(traceback.format_exc(), fg='red')
#             else:
#                 click.secho(str(e), fg='red')
#             raise click.Abort
#         except ConfigError as e:
#             click.secho(str(e), fg='red')
#             if ctx.obj.verbosity > 0:
#                 traceback.print_exc()
#             raise click.Abort
# 
#     return wrapper
# 
# Path: awscfncli2/runner/commands/stack_delete_command.py
# class StackDeleteOptions(namedtuple('StackDeleteOptions',
#                                     ['no_wait',
#                                      'ignore_missing'])):
#     pass
# 
# class StackDeleteCommand(Command):
#     SKIP_UPDATE_REFERENCES = True
# 
#     def run(self, stack_context):
#         # stack contexts
#         session = stack_context.session
#         parameters = stack_context.parameters
#         metadata = stack_context.metadata
# 
#         self.ppt.pprint_stack_name(stack_context.stack_key,
#                                    parameters['StackName'],
#                                    'Deleting stack ')
# 
#         # create boto3 cfn resource
#         cfn = session.resource('cloudformation')
#         self.ppt.pprint_session(session)
#         self.ppt.pprint_parameters(parameters)
# 
#         # call boto3
#         stack = cfn.Stack(parameters['StackName'])
#         try:
#             update_termination_protection(
#                 session,
#                 parameters.pop('EnableTerminationProtection', None),
#                 parameters['StackName'],
#                 self.ppt)
#             self.ppt.pprint_stack(stack)
#             stack.delete()
#         except Exception as ex:
#             if self.options.ignore_missing and \
#                     is_stack_does_not_exist_exception(ex):
#                 self.ppt.secho(str(ex), fg='red')
#                 return
#             else:
#                 raise
# 
#         # wait until delete complete
#         if self.options.no_wait:
#             self.ppt.secho('Stack is being deleted.')
#         else:
#             self.ppt.wait_until_delete_complete(session, stack)
#             self.ppt.secho('Stack delete complete.', fg='green')


# Path: awscfncli2/cli/commands/stack/delete/delete.py
import click
from awscfncli2.cli.context import Context
from awscfncli2.cli.utils.deco import command_exception_handler
from awscfncli2.runner.commands.stack_delete_command import StackDeleteOptions, \
    StackDeleteCommand

#  -*- encoding: utf-8 -*-




@click.command()
@click.option('--quiet', '-q', is_flag=True, default=False,
              help='Suppress warning if more than one stack is being deleted.')
@click.option('--no-wait', '-w', is_flag=True, default=False,
              help='Exit immediately after delete is started.')
@click.option('--ignore-missing', '-i', is_flag=True, default=False,
              help='Don\'t exit with error if the stack is missing.')
@click.pass_context

@command_exception_handler