diff --git a/spectacles/cli.py b/spectacles/cli.py index 8943550d..e2db9a6a 100644 --- a/spectacles/cli.py +++ b/spectacles/cli.py @@ -529,7 +529,7 @@ def _build_lookml_subparser( ) subparser.add_argument( "--severity", - choices=["info", "warning", "error"], + choices=["success", "info", "warning", "error", "fatal"], default="warning", help=( "Specify a level of validation error severity to trigger test failure. " diff --git a/spectacles/printer.py b/spectacles/printer.py index 448ed17a..53099e7f 100644 --- a/spectacles/printer.py +++ b/spectacles/printer.py @@ -93,11 +93,11 @@ def print_lookml_error( ) -> None: if file_path is None: file_path = "[File name not given by Looker]" - header_color = yellow if severity == "warning" else red + header_color = red if severity in ("fatal", "error") else yellow print_header( header_color(f"{file_path}:{line_number}"), LINE_WIDTH + COLOR_CODE_LENGTH ) - wrapped = textwrap.fill(f"{severity.title()}: {message}", LINE_WIDTH) + wrapped = textwrap.fill(f"[{severity.title()}] {message}", LINE_WIDTH) logger.info(wrapped) if lookml_url: logger.info("\n" + f"LookML: {lookml_url}") diff --git a/spectacles/validators/lookml.py b/spectacles/validators/lookml.py index e1892a3c..112a556c 100644 --- a/spectacles/validators/lookml.py +++ b/spectacles/validators/lookml.py @@ -3,10 +3,19 @@ from spectacles.exceptions import LookMLError # Define constants for severity levels +SUCCESS = 0 INFO = 10 WARNING = 20 ERROR = 30 -NAME_TO_LEVEL = {"info": INFO, "warning": WARNING, "error": ERROR} +FATAL = 40 + +NAME_TO_LEVEL = { + "success": SUCCESS, + "info": INFO, + "warning": WARNING, + "error": ERROR, + "fatal": FATAL, +} class LookMLValidator: @@ -22,7 +31,7 @@ def __init__(self, client: LookerClient): self.client = client def validate(self, project: str, severity: str = "warning") -> Dict[str, Any]: - severity_level = NAME_TO_LEVEL[severity] + severity_level: int = NAME_TO_LEVEL[severity] validation_results = self.client.lookml_validation(project) errors = [] lookml_url: Optional[str] = None