diff --git a/src/sounddiff/cli.py b/src/sounddiff/cli.py index 2355aa9..0b97a19 100644 --- a/src/sounddiff/cli.py +++ b/src/sounddiff/cli.py @@ -20,8 +20,8 @@ @click.command() -@click.argument("file_a", type=click.Path(exists=True)) -@click.argument("file_b", type=click.Path(exists=True)) +@click.argument("file_a", type=click.Path()) +@click.argument("file_b", type=click.Path()) @click.option( "--format", "output_format", @@ -65,6 +65,31 @@ def main( Compares FILE_A (reference) against FILE_B (comparison) and reports differences in loudness, spectral content, timing, and potential issues. """ + console = Console() + + # Validate file_a + path_a = pathlib.Path(file_a) + if not path_a.exists(): + console.print(f"[red]Error:[/red] File not found: [bold]{file_a}[/bold]") + console.print(f"[dim]Looked in: {path_a.parent.absolute()}[/dim]") + console.print("[dim]Tip: Check the file path and make sure the file exists.[/dim]") + sys.exit(1) + + # Validate file_b + path_b = pathlib.Path(file_b) + if not path_b.exists(): + console.print(f"[red]Error:[/red] sounddiff needs two files to compare.") + console.print(f"[dim]Got: {file_a} (exists), but {file_b} not found.[/dim]") + console.print(f"[dim]Looked in: {path_b.parent.absolute()}[/dim]") + sys.exit(1) + + # Validate audio file extensions + audio_extensions = {'.wav', '.mp3', '.flac', '.ogg', '.m4a', '.aac', '.wma', '.aiff', '.aif'} + for file_path, arg_name in [(path_a, 'FILE_A'), (path_b, 'FILE_B')]: + if file_path.suffix.lower() not in audio_extensions: + console.print(f"[yellow]Warning:[/yellow] {arg_name} ('{file_path.name}') may not be an audio file.") + console.print(f"[dim]Expected audio formats: {', '.join(sorted(audio_extensions))}[/dim]") + # Best-effort duration probe: if sf.info() fails for either file, # skip the progress bar and let diff() raise the proper error message. show_progress = False