Skip to content

bug(cli): --diff-from silently ignores --json flag #150

@rocketman-code

Description

@rocketman-code

Current Behavior

Running `chainsaw trace --diff-from snapshot.json --json src/index.ts` ignores the `--json` flag and always outputs terminal-formatted text.

Expected Behavior

When `--json` is specified alongside `--diff-from`, the diff result should be output as JSON.

Context

Users who want to programmatically compare snapshots cannot get machine-readable output from `--diff-from`.

Technical Details

Relevant Code

`src/main.rs:334-340` -- run_trace

```rust
if let Some(ref snapshot_path) = args.diff_from {
let saved = load_snapshot(snapshot_path)?;
let diff = query::diff_snapshots(&saved, &result.to_snapshot(&entry_rel));
let report = report::DiffReport::from_diff(&diff, &saved.entry, &entry_rel, args.limit);
print!("{}", report.to_terminal(color));
return Ok(());
}
```

The `--diff-from` branch unconditionally calls `to_terminal()` without checking `args.json`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low prioritybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions