Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions src/sounddiff/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

The error console doesn't respect --no-color.

The Console() instance created here will always output colors, ignoring the --no-color flag. The progress console at line 120 correctly passes no_color=no_color.

🐛 Proposed fix
-    console = Console()
+    console = Console(no_color=no_color)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console = Console()
console = Console(no_color=no_color)


# 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
Expand Down