summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/README.md.template11
-rw-r--r--example/simple-ex.zig (renamed from example/comptime-clap.zig)4
2 files changed, 3 insertions, 12 deletions
diff --git a/example/README.md.template b/example/README.md.template
index 65b507d..530cea4 100644
--- a/example/README.md.template
+++ b/example/README.md.template
@@ -50,14 +50,7 @@ zig-clap/example/simple-error.zig:16:18: note: called from here
50 _ = args.flag("--helps"); 50 _ = args.flag("--helps");
51``` 51```
52 52
53### `ComptimeClap` 53There is also a `parseEx` variant that takes an argument iterator.
54
55The `ComptimeClap` is the parser used by `clap.parse`. It allows the user to use a custom argument
56iterator.
57
58```zig
59{}
60```
61 54
62### `StreamingClap` 55### `StreamingClap`
63 56
@@ -68,7 +61,7 @@ The `StreamingClap` is the base of all the other parsers. It's a streaming parse
68{} 61{}
69``` 62```
70 63
71Currently, this parse is the only parser that allow an array of `Param` that 64Currently, this parse is the only parser that allow an array of `Param` tha
72is generated at runtime. 65is generated at runtime.
73 66
74### `help` 67### `help`
diff --git a/example/comptime-clap.zig b/example/simple-ex.zig
index e5d02ff..d6ecc44 100644
--- a/example/comptime-clap.zig
+++ b/example/simple-ex.zig
@@ -14,7 +14,6 @@ pub fn main() !void {
14 clap.parseParam("-s, --string <STR>... An option parameter which can be specified multiple times.") catch unreachable, 14 clap.parseParam("-s, --string <STR>... An option parameter which can be specified multiple times.") catch unreachable,
15 clap.parseParam("<POS>...") catch unreachable, 15 clap.parseParam("<POS>...") catch unreachable,
16 }; 16 };
17 const Clap = clap.ComptimeClap(clap.Help, clap.args.OsIterator, &params);
18 17
19 // We then initialize an argument iterator. We will use the OsIterator as it nicely 18 // We then initialize an argument iterator. We will use the OsIterator as it nicely
20 // wraps iterating over arguments the most efficient way on each os. 19 // wraps iterating over arguments the most efficient way on each os.
@@ -26,8 +25,7 @@ pub fn main() !void {
26 // don't care about the extra information `Diagnostics` provides. 25 // don't care about the extra information `Diagnostics` provides.
27 var diag: clap.Diagnostic = undefined; 26 var diag: clap.Diagnostic = undefined;
28 27
29 // Parse the arguments 28 var args = clap.parseEx(clap.Help, &params, allocator, &iter, &diag) catch |err| {
30 var args = Clap.parse(allocator, &iter, &diag) catch |err| {
31 // Report useful error and exit 29 // Report useful error and exit
32 diag.report(std.io.getStdErr().outStream(), err) catch {}; 30 diag.report(std.io.getStdErr().outStream(), err) catch {};
33 return err; 31 return err;