refactor: make logger parameter optional
This commit is contained in:
@@ -1,17 +1,21 @@
|
|||||||
"""Safeguard module for Skywipe"""
|
"""Safeguard module for Skywipe"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
|
from typing import Optional
|
||||||
from .logger import get_logger
|
from .logger import get_logger
|
||||||
|
|
||||||
|
|
||||||
CONFIRM_RESPONSES = {"yes", "y"}
|
CONFIRM_RESPONSES = {"yes", "y"}
|
||||||
|
|
||||||
|
|
||||||
def require_confirmation(operation: str, skip_confirmation: bool = False) -> None:
|
def require_confirmation(operation: str, skip_confirmation: bool = False, logger: Optional[logging.Logger] = None) -> None:
|
||||||
if skip_confirmation:
|
if skip_confirmation:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if logger is None:
|
||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
|
|
||||||
logger.warning(f"This will {operation}")
|
logger.warning(f"This will {operation}")
|
||||||
logger.warning("This operation is DESTRUCTIVE and cannot be undone!")
|
logger.warning("This operation is DESTRUCTIVE and cannot be undone!")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user