Skip to content

Commit 33a939d

Browse files
authored
Merge pull request #1 from yves-biener/main
doc: update Install section
2 parents c6ca205 + 5ca89d4 commit 33a939d

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,43 @@ time. It supports:
1616

1717
## Install
1818

19+
Add or update this library as a dependency in your zig project run the following command:
20+
21+
```sh
22+
zig fetch --save git+https://github.com/nilslice/zig-interface
23+
```
24+
25+
Afterwards add the library as a dependency to any module in your _build.zig_:
26+
27+
```zig
28+
// ...
29+
const interface_dependency = b.dependency("interface", .{
30+
.target = target,
31+
.optimize = optimize,
32+
});
33+
34+
const exe = b.addExecutable(.{
35+
.name = "main",
36+
.root_source_file = b.path("src/main.zig"),
37+
.target = target,
38+
.optimize = optimize,
39+
});
40+
// import the exposed `interface` module from the dependency
41+
exe.root_module.addImport("interface", interface_dependency.module("interface"));
42+
// ...
1943
```
20-
TODO
44+
45+
In the end you can import the `interface` module. For example:
46+
47+
```zig
48+
const Interface = @import("interface").Interface;
49+
50+
const Repository = Interface(.{
51+
.create = fn(anytype, User) anyerror!u32,
52+
.findById = fn(anytype, u32) anyerror!?User,
53+
.update = fn(anytype, User) anyerror!void,
54+
.delete = fn(anytype, u32) anyerror!void,
55+
}, null);
2156
```
2257

2358
## Usage

0 commit comments

Comments
 (0)