Skip to content

Commit

Permalink
fix(cli): return exit code for unprocessed
Browse files Browse the repository at this point in the history
  • Loading branch information
guilatrova committed Jul 20, 2021
1 parent 70bfa7d commit 50df1dc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/tryceratops/interfaces.py
@@ -1,6 +1,7 @@
import logging
import os
import sys
from enum import IntEnum

from tryceratops.analyzers import Runner
from tryceratops.files.discovery import FileDiscovery
Expand All @@ -16,6 +17,13 @@ class COLORS:
ENDC = "\033[0m"


class ExitCodes(IntEnum):
SUCCESS = 0
LINT_BROKEN = 1
UNPROCESSED_FILE = 2
RUNTIME_ISSUES = 100


def wrap_color(msg: str, color: str):
return f"{color}{msg}{COLORS.ENDC}"

Expand Down Expand Up @@ -61,12 +69,14 @@ def _present_status(self):
)

def _exit(self):
exit_code = 0
exit_code = ExitCodes.SUCCESS

if self.runner.had_issues:
exit_code = 2
exit_code = ExitCodes.RUNTIME_ISSUES
elif self.discovery.had_issues:
exit_code = ExitCodes.UNPROCESSED_FILE
elif self.runner.any_violation:
exit_code = 1
exit_code = ExitCodes.LINT_BROKEN

sys.exit(exit_code)

Expand Down

0 comments on commit 50df1dc

Please sign in to comment.