diff --git a/src/sounddiff/cli.py b/src/sounddiff/cli.py index 2355aa9..ad3201b 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(), required=False) +@click.argument("file_b", type=click.Path(), required=False) @click.option( "--format", "output_format", @@ -51,8 +51,8 @@ ) @click.version_option(version=__version__, prog_name="sounddiff") def main( - file_a: str, - file_b: str, + file_a: str | None, + file_b: str | None, output_format: str, output_path: str | None, verbose: bool, @@ -65,6 +65,34 @@ def main( Compares FILE_A (reference) against FILE_B (comparison) and reports differences in loudness, spectral content, timing, and potential issues. """ + console = Console() + + # No arguments provided - show help + if file_a is None: + ctx = click.get_current_context() + click.echo(ctx.get_help()) + sys.exit(0) + + # Only one file provided + if file_b is None: + console.print("[red]Error:[/red] sounddiff needs two files to compare.") + console.print(f"[dim]Got: {file_a}[/dim]") + console.print("[dim]Usage: sounddiff FILE_A FILE_B[/dim]") + sys.exit(1) + + # 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]") + sys.exit(1) + + # Validate file_b + path_b = pathlib.Path(file_b) + if not path_b.exists(): + console.print(f"[red]Error:[/red] File not found: [bold]{file_b}[/bold]") + console.print(f"[dim]Looked in: {path_b.parent.absolute()}[/dim]") + sys.exit(1) # 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