summaryrefslogtreecommitdiff
path: root/example/README.md.template
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--example/README.md.template50
1 files changed, 30 insertions, 20 deletions
diff --git a/example/README.md.template b/example/README.md.template
index 373a037..1fd90b0 100644
--- a/example/README.md.template
+++ b/example/README.md.template
@@ -15,45 +15,55 @@ A simple and easy to use command line argument parser library for Zig.
15 15
16## Examples 16## Examples
17 17
18### `StreamingClap` 18### `clap.parse`
19 19
20The `StreamingClap` is the base of all the other parsers. It's a streaming parser that uses an 20The simplest way to use this library is to just call the `clap.parse` function.
21`args.Iterator` to provide it with arguments lazily.
22 21
23```zig 22```zig
24{} 23{}
25``` 24```
26 25
27### `ComptimeClap` 26The data structure returned has lookup speed on par with array access (`arr[i]`) and validates
28 27that the strings you pass to `option` and `flag` are actually parameters that the program can take:
29The `ComptimeClap` is a wrapper for `StreamingClap`, which parses all the arguments and makes
30them available through three functions (`flag`, `option`, `positionals`).
31
32```zig
33{}
34```
35
36The data structure returned from this parser has lookup speed on par with array access (`arr[i]`)
37and validates that the strings you pass to `option` and `flag` are actually parameters that the
38program can take:
39 28
40```zig 29```zig
41{} 30{}
42``` 31```
43 32
44``` 33```
45zig-clap/src/comptime.zig:109:17: error: --helps is not a parameter. 34zig-clap/clap/comptime.zig:109:17: error: --helps is not a parameter.
46 @compileError(name ++ " is not a parameter."); 35 @compileError(name ++ " is not a parameter.");
47 ^ 36 ^
48zig-clap/src/comptime.zig:77:45: note: called from here 37zig-clap/clap/comptime.zig:77:45: note: called from here
49 const param = comptime findParam(name); 38 const param = comptime findParam(name);
50 ^ 39 ^
51zig-clap/example/comptime-clap-error.zig:18:18: note: called from here 40zig-clap/clap.zig:238:31: note: called from here
41 return a.clap.flag(name);
42 ^
43zig-clap/example/simple-error.zig:16:18: note: called from here
52 _ = args.flag("--helps"); 44 _ = args.flag("--helps");
53 ^
54``` 45```
55 46
56Ofc, this limits you to parameters that are comptime known. 47### `ComptimeClap`
48
49The `ComptimeClap` is the parser used by `clap.parse`. It allows the user to use a custom argument
50iterator.
51
52```zig
53{}
54```
55
56### `StreamingClap`
57
58The `StreamingClap` is the base of all the other parsers. It's a streaming parser that uses an
59`args.Iterator` to provide it with arguments lazily.
60
61```zig
62{}
63```
64
65Currently, this parse is the only parser that allow an array of `Param` that
66is generated at runtime.
57 67
58### `help` 68### `help`
59 69