#!/usr/bin/env python3

import subprocess
import sys

from tools.python_tools import lintable_tools_files


python_sources = [
    "zulipterminal/",
    "tests/",
    "setup.py",
]

python_sources += lintable_tools_files

tools = {
    "Import order (isort)": "./tools/run-isort-check",
    "Type consistency (mypy)": "./tools/run-mypy",
    "PEP8 & more (flake8)": ["flake8"] + python_sources,
    "Formatting (black)": ["black", "--check"] + python_sources,
}

for tool_name, command in tools.items():
    print(80 * "=")
    print(tool_name)
    print(80 * "-")
    result = subprocess.call(command)
    if result != 0:
        print(80 * "=")
        print("LINTING FAILED")
        sys.exit(1)

print(80 * "=")
print("LINTING SUCCESSFUL")
