2025-12-23 12:33:42 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
2025-12-23 11:14:24 +01:00
|
|
|
from .cli import parse_args
|
2025-12-23 12:33:42 +01:00
|
|
|
from .config import config_from_env_and_args
|
2025-12-23 11:14:24 +01:00
|
|
|
from .errors import BootstrapError
|
2025-12-23 12:33:42 +01:00
|
|
|
from .service import run
|
2025-12-23 11:14:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> int:
|
|
|
|
|
args = parse_args()
|
|
|
|
|
|
|
|
|
|
try:
|
2025-12-23 12:33:42 +01:00
|
|
|
config = config_from_env_and_args(args)
|
|
|
|
|
token = run(config)
|
2025-12-23 11:14:24 +01:00
|
|
|
print(token)
|
|
|
|
|
return 0
|
2025-12-23 12:33:42 +01:00
|
|
|
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())
|