Add graceful exit handling for Ctrl+C interrupts

This commit is contained in:
Jarian Cottingham 2026-02-21 15:00:11 -06:00
parent cb1a201107
commit a2e8042f27

View File

@ -6,6 +6,7 @@ YouTube CLI - A command-line interface for browsing and downloading YouTube vide
import argparse
import json
import os
import signal
import subprocess
import sys
import time
@ -1004,8 +1005,16 @@ class YouTubeCLI:
console.print(f"[red]Error during playlist download: {str(e)}[/red]")
def signal_handler(sig, frame):
"""Handle Ctrl+C gracefully."""
console.print("\n[yellow]Operation cancelled by user.[/yellow]")
sys.exit(0)
def main():
"""Main entry point for the YouTube CLI application."""
# Register signal handler for Ctrl+C
signal.signal(signal.SIGINT, signal_handler)
parser = argparse.ArgumentParser(
description="YouTube CLI - Browse and download videos from YouTube"
)