Skip to content

Commit 9ba8af9

Browse files
randleeclaude
andcommitted
docs: Update CLI API documentation for v0.7.0 redesign
- Update README with new CLI output format options (--json, --html, --text, --git) - Add output control flags (--quiet, --no-color, --open) - Document exit codes for CI/CD usage (0=no diff, 1=diff, 2=error) - Add comprehensive CLI output test coverage to plan - Add sample updates checklist for post-implementation - Document combined output use cases (AI: JSON + HTML for human) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ec5a2a7 commit 9ba8af9

File tree

2 files changed

+287
-68
lines changed

2 files changed

+287
-68
lines changed

README.md

Lines changed: 97 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,20 @@ dotnet run -- diff old.cs new.cs
4848
### Compare Two Files
4949

5050
```bash
51-
# Basic diff
51+
# Basic diff (colored output if terminal, plain if piped)
5252
roslyn-diff diff old.cs new.cs
5353

54+
# AI use case: JSON for processing + HTML for human review
55+
roslyn-diff diff old.cs new.cs --json --html report.html --open
56+
5457
# Output as JSON (for AI/tooling consumption)
55-
roslyn-diff diff old.cs new.cs --output json
58+
roslyn-diff diff old.cs new.cs --json
5659

57-
# Generate HTML report
58-
roslyn-diff diff old.cs new.cs --output html --out-file report.html
60+
# Generate HTML report and open in browser
61+
roslyn-diff diff old.cs new.cs --html report.html --open
5962

60-
# Rich terminal output with colors
61-
roslyn-diff diff old.cs new.cs --rich
63+
# Git-style unified diff (patchable)
64+
roslyn-diff diff old.cs new.cs --git
6265
```
6366

6467
### Compare Specific Classes
@@ -91,16 +94,32 @@ roslyn-diff diff <old-file> <new-file> [options]
9194
- `<old-file>` - Path to the original file
9295
- `<new-file>` - Path to the modified file
9396

94-
**Options:**
97+
**Output Format Options (can combine multiple):**
98+
| Option | Description |
99+
|--------|-------------|
100+
| `--json [file]` | JSON output (stdout if no file, or to specified file) |
101+
| `--html <file>` | HTML report to file (required: file path) |
102+
| `--text [file]` | Plain text diff (stdout if no file) |
103+
| `--git [file]` | Git-style unified diff (stdout if no file) |
104+
| `--open` | Open HTML in default browser after generation |
105+
106+
**Output Control:**
107+
| Option | Description |
108+
|--------|-------------|
109+
| `--quiet` | Suppress default console output (for scripting) |
110+
| `--no-color` | Disable colored output even if terminal supports it |
111+
112+
**Diff Mode Options:**
95113
| Option | Short | Description | Default |
96114
|--------|-------|-------------|---------|
97115
| `--mode <mode>` | `-m` | Diff mode: `auto`, `roslyn`, `line` | `auto` |
98116
| `--ignore-whitespace` | `-w` | Ignore whitespace differences | `false` |
99117
| `--ignore-comments` | `-c` | Ignore comment differences (Roslyn mode only) | `false` |
100118
| `--context <lines>` | `-C` | Lines of context to show | `3` |
101-
| `--output <format>` | `-o` | Output format: `json`, `html`, `text`, `plain`, `terminal` | `text` |
102-
| `--out-file <path>` | | Write output to file instead of stdout | |
103-
| `--rich` | `-r` | Use rich terminal output with colors | `false` |
119+
120+
**Default Behavior:**
121+
- If no format flags: colored console output (if TTY) or plain text (if piped)
122+
- Multiple formats can be combined (e.g., `--json --html report.html`)
104123

105124
**Diff Modes:**
106125
- `auto` - Automatically select based on file extension (.cs/.vb use Roslyn, others use line diff)
@@ -119,27 +138,46 @@ roslyn-diff class <old-spec> <new-spec> [options]
119138
- `<old-spec>` - Old file specification: `file.cs:ClassName` or `file.cs`
120139
- `<new-spec>` - New file specification: `file.cs:ClassName` or `file.cs`
121140

122-
**Options:**
141+
**Options (same format options as diff command, plus):**
123142
| Option | Short | Description | Default |
124143
|--------|-------|-------------|---------|
125144
| `--match-by <strategy>` | `-m` | Matching strategy: `exact`, `interface`, `similarity`, `auto` | `auto` |
126145
| `--interface <name>` | `-i` | Interface name for interface matching | |
127146
| `--similarity <threshold>` | `-s` | Similarity threshold (0.0-1.0) | `0.8` |
128-
| `--output <format>` | `-o` | Output format: `json`, `html`, `text`, `plain`, `terminal` | `text` |
129-
| `--out-file <path>` | `-f` | Write output to file | |
130147

131148
**Match Strategies:**
132149
- `exact` - Match classes by exact name
133150
- `interface` - Match classes implementing the specified interface
134151
- `similarity` - Match by content similarity (for renamed classes)
135152
- `auto` - Try exact name first, then similarity
136153

154+
## Exit Codes (CI/CD Friendly)
155+
156+
| Code | Meaning |
157+
|------|---------|
158+
| `0` | No differences found |
159+
| `1` | Differences found (success, but files differ) |
160+
| `2` | Error (file not found, parse error, etc.) |
161+
162+
**Example CI usage:**
163+
```bash
164+
roslyn-diff diff old.cs new.cs --quiet && echo "No changes"
165+
```
166+
137167
## Output Formats
138168

139-
### JSON (`--output json`)
169+
### JSON (`--json`)
140170

141171
Machine-readable format, ideal for AI consumption and tooling integration.
142172

173+
```bash
174+
# To stdout (for piping to jq, AI tools, etc.)
175+
roslyn-diff diff old.cs new.cs --json
176+
177+
# To file
178+
roslyn-diff diff old.cs new.cs --json analysis.json
179+
```
180+
143181
```json
144182
{
145183
"$schema": "roslyn-diff-output-v1",
@@ -159,38 +197,69 @@ Machine-readable format, ideal for AI consumption and tooling integration.
159197
}
160198
```
161199

162-
### HTML (`--output html`)
200+
### HTML (`--html`)
163201

164202
Interactive HTML report with:
165203
- Side-by-side diff view
166204
- Syntax highlighting
167-
- Collapsible sections
205+
- Collapsible sections with copy buttons
206+
- IDE integration links (VS Code, Rider, PyCharm, Zed)
168207
- Navigation and summary statistics
169208

170-
### Text (`--output text`)
209+
```bash
210+
# Generate and open in browser
211+
roslyn-diff diff old.cs new.cs --html report.html --open
212+
```
213+
214+
### Text (`--text`)
171215

172-
Unified diff format, similar to `git diff`:
216+
Structured plain text showing semantic changes:
217+
218+
```bash
219+
roslyn-diff diff old.cs new.cs --text
220+
```
221+
222+
```
223+
Diff: old.cs -> new.cs
224+
Mode: Roslyn (semantic)
225+
226+
Summary: +2 (2 total changes)
227+
228+
Changes:
229+
File: new.cs
230+
[+] Method: Multiply (line 5-8)
231+
[+] Method: Divide (line 10-13)
232+
```
233+
234+
### Git Unified Diff (`--git`)
235+
236+
Standard unified diff format, compatible with `patch` command:
237+
238+
```bash
239+
roslyn-diff diff old.cs new.cs --git
240+
```
173241

174242
```diff
175243
--- old/Calculator.cs
176244
+++ new/Calculator.cs
177-
@@ class Calculator @@
178-
+ public int Multiply(int a, int b)
179-
+ {
180-
+ return a * b;
181-
+ }
245+
@@ -1,7 +1,12 @@
246+
public class Calculator
247+
{
248+
public int Add(int a, int b) => a + b;
249+
+ public int Multiply(int a, int b) => a * b;
250+
}
182251
```
183252

184-
### Terminal (`--output terminal` or `--rich`)
253+
### Console Output (default)
185254

186-
Rich terminal output using Spectre.Console with:
255+
When connected to a terminal (TTY):
187256
- Color-coded changes (green for additions, red for deletions)
188257
- Tree view for structural changes
189258
- Summary tables
190259

191-
### Plain (`--output plain`)
192-
193-
Simple text output without ANSI codes, suitable for piping and redirection.
260+
When piped/redirected:
261+
- Falls back to plain text format
262+
- No ANSI escape codes
194263

195264
## Change Types Detected
196265

0 commit comments

Comments
 (0)