#!/usr/bin/env python3
"""Return list of application source files from CWD on down."""

import subprocess


def srcs() -> list[str]:
    """Return list of application source files from CWD on down."""

    exts = [
        "css",
        "html",
        "js",
        "py",
        "rb",
    ]
    find = "/usr/bin/find . " + " -o ".join([f"-name '*.{x}'" for x in exts])

    excl = [
        ".junk/",
        ".mypy_cache/",
        ".tox/",
        ".venv/",
        ".vscode/",
        "__pycache__/",
        "__pypackages__/",
        "build/",
        "gems/",
        "htmlcov/",
        "node_modules/",
        "pytest_cache/",
        "setup.py",
    ]
    grep = "/usr/bin/grep -v " + " ".join([f"-e {e}" for e in excl])

    proc = subprocess.run(
        f"{find} | {grep}", capture_output=True, check=True, shell=True, text=True
    )

    return sorted(proc.stdout.splitlines()) if proc.returncode == 0 else []


def main() -> None:
    """CLI entry point."""
    for src in srcs():
        print(src)


if __name__ == "__main__":
    main()
