"""`puga [args]`: run a tool from tools/ (installed as the `puga` command by pip install -e .).""" import runpy, sys from . import ROOT ALIASES = {"plan": "plan_push"} def _tools(): return sorted(p.stem for p in (ROOT / "tools").glob("*.py")) def main(): args = sys.argv[1:] if not args or args[0] in ("-h", "--help", "help"): print("usage: puga [args]\n\ntools:") for t in _tools(): print(" " + ("plan (plan_push)" if t == "plan_push" else t)) print(" test (run the test suite)") return tool, rest = args[0], args[1:] if tool == "test": import pytest sys.exit(pytest.main(["-q", *rest])) tool = ALIASES.get(tool, tool) path = ROOT / "tools" / f"{tool}.py" if not path.exists(): sys.exit(f"unknown tool '{tool}' (try: puga help)") sys.argv = [str(path), *rest] runpy.run_path(str(path), run_name="__main__")