import pathlib
import os
import subprocess

def run_format_headers():
    root = "../../src"
    script = "../../commit-config/hooks/formatHeader.py"

    validExtensions = [".c", ".h", ".cpp", ".hpp", ".py", ".f", ".f90"]

    for path in pathlib.Path(root).rglob("*"):
        if path.is_file() and path.suffix in validExtensions:
            print(f"Adding header to: {path}")
            subprocess.run(["python", script, str(path)], stdout=subprocess.PIPE)

if __name__ == "__main__":
    run_format_headers()
