Files
matomo-bootstrap/src/matomo_bootstrap/__main__.py
Kevin Veen-Birkenbach 5dbb1857c9 refactor: remove bootstrap wrappers and split into config/service/installers
- Replace bootstrap wrapper with config-driven service orchestration
- Introduce Config dataclass for centralized env/CLI validation
- Add MatomoApi service for session login + app token creation
- Move Playwright installer into installers/web and drop old install package
- Refactor HttpClient to unify HTTP handling and debug to stderr
- Make E2E tests use sys.executable instead of hardcoded python3
2025-12-23 12:33:42 +01:00

33 lines
756 B
Python

from __future__ import annotations
import sys
from .cli import parse_args
from .config import config_from_env_and_args
from .errors import BootstrapError
from .service import run
def main() -> int:
args = parse_args()
try:
config = config_from_env_and_args(args)
token = run(config)
print(token)
return 0
except ValueError as exc:
# config validation errors
print(f"[ERROR] {exc}", file=sys.stderr)
return 2
except BootstrapError as exc:
print(f"[ERROR] {exc}", file=sys.stderr)
return 2
except Exception as exc:
print(f"[FATAL] {type(exc).__name__}: {exc}", file=sys.stderr)
return 3
if __name__ == "__main__":
raise SystemExit(main())