Files
matomo-bootstrap/src/matomo_bootstrap/__main__.py

33 lines
756 B
Python
Raw Normal View History

from __future__ import annotations
import sys
2025-12-23 11:14:24 +01:00
from .cli import parse_args
from .config import config_from_env_and_args
2025-12-23 11:14:24 +01:00
from .errors import BootstrapError
from .service import run
2025-12-23 11:14:24 +01:00
def main() -> int:
args = parse_args()
try:
config = config_from_env_and_args(args)
token = run(config)
2025-12-23 11:14:24 +01:00
print(token)
return 0
except ValueError as exc:
# config validation errors
print(f"[ERROR] {exc}", file=sys.stderr)
return 2
2025-12-23 11:14:24 +01:00
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())