import argparse
from controllers.controller import AppController
from utils.logger import get_logger

if __name__ == "__main__":
    logger = get_logger("Main")
    parser = argparse.ArgumentParser(description="VOC Notification App")
    parser.add_argument("--test", action="store_true", help="Run in test mode (no web crawling, use local DB)")
    parser.add_argument(
        "--test-update-now",
        action="store_true",
        help="In test mode, run updater check once right after startup",
    )
    args = parser.parse_args()

    mode_str = "[TEST MODE]" if args.test else "[LIVE MODE]"
    logger.info(f"== Application Startup {mode_str} ==")

    try:
        app = AppController(test_mode=args.test, test_update_now=args.test_update_now)
        app.start_background()
    except Exception as e:
        logger.critical(f"Application Crashed: {e}", exc_info=True)
