sdiff/README.md
2025-09-01 03:21:54 +03:00

65 lines
953 B
Markdown

# Simply Diff
A minimal D wrapper over [xdiff.d](https://git.zhirov.kz/dlang/xdiff) for computing file differences and generating patches.
## Features
* Create in-memory files (`MMFile`) from strings, string arrays, or raw bytes.
* Compute diffs between two in-memory files.
* Collect results as `MMBlocks`, convertible to a string or byte slice.
## Installation
Add to `dub.json`:
```json
{
"dependencies": {
"sdiff": "~>0.1.0"
}
}
```
Or
```json
{
"dependencies": {
"sdiff": {
"repository": "git+https://git.zhirov.kz/dlang/sdiff.git",
"version": "<hash from git>"
}
}
}
```
Run `dub build`.
## Example
```d
import sdiff;
import std.stdio : writeln;
void main()
{
auto a = new MMFile("hello world\n");
auto b = new MMFile("hello world!\n");
auto patch = a.diff(b);
writeln(patch);
}
```
Output:
```diff
@@ -1,1 +1,1 @@
-hello world
+hello world!
```
## License
Boost Software License 1.0. See [LICENSE](LICENSE).