def confirmation_option(*param_decls, **attrs):
 def decorator(f):
  def callback(ctx, param, value):
   if (not value):
    ctx.abort()
  attrs.setdefault('is_flag', True)
  attrs.setdefault('callback', callback)
  attrs.setdefault('expose_value', False)
  attrs.setdefault('prompt', 'Do you want to continue?')
  attrs.setdefault('help', 'Confirm the action without prompting.')
  return option(*(param_decls or ('--yes',)), **attrs)(f)
 return decorator

def confirmation_option ( * param_decls , ** attrs ) : def decorator ( f ) : def callback ( ctx , param , value ) : if ( not value ) : ctx . abort ( ) attrs . setdefault ( 'is_flag' , True ) attrs . setdefault ( 'callback' , callback ) attrs . setdefault ( 'expose_value' , False ) attrs . setdefault ( 'prompt' , 'Do you want to continue?' ) attrs . setdefault ( 'help' , 'Confirm the action without prompting.' ) return option ( * ( param_decls or ( '--yes' , ) ) , ** attrs ) ( f ) return decorator
shortcut for confirmation prompts that can be ignored by passing --yes as parameter .