summaryrefslogtreecommitdiff
path: root/example/README.md.template
diff options
context:
space:
mode:
authorGravatar JustAnotherCodemonkey2024-11-25 07:57:42 +0000
committerGravatar GitHub2024-11-25 08:57:42 +0100
commit560c8dd72ab25d556123846254040c5bf9ad3ba4 (patch)
treea5c57b24b67fdc1fc71abf444d422062453921be /example/README.md.template
parentrefactor: switch on signedness (diff)
downloadzig-clap-560c8dd72ab25d556123846254040c5bf9ad3ba4.tar.gz
zig-clap-560c8dd72ab25d556123846254040c5bf9ad3ba4.tar.xz
zig-clap-560c8dd72ab25d556123846254040c5bf9ad3ba4.zip
Patch up README and fix comments in example files. (#143)
The readme was also reflowed to 100 cols. I probably should have put that in a separate commit but oh well. The comments were not subjected to reflowing (yet).
Diffstat (limited to 'example/README.md.template')
-rw-r--r--example/README.md.template28
1 files changed, 13 insertions, 15 deletions
diff --git a/example/README.md.template b/example/README.md.template
index bcd3774..bbf5cb8 100644
--- a/example/README.md.template
+++ b/example/README.md.template
@@ -45,8 +45,8 @@ exe.root_module.addImport("clap", clap.module("clap"));
45 45
46## API Reference 46## API Reference
47 47
48Automatically generated API Reference for the project 48Automatically generated API Reference for the project can be found at https://Hejsil.github.io/
49can be found at https://Hejsil.github.io/zig-clap. 49zig-clap.
50Note that Zig autodoc is in beta; the website may be broken or incomplete. 50Note that Zig autodoc is in beta; the website may be broken or incomplete.
51 51
52## Examples 52## Examples
@@ -59,16 +59,16 @@ The simplest way to use this library is to just call the `clap.parse` function.
59{s} 59{s}
60``` 60```
61 61
62The result will contain an `args` field and a `positionals` field. `args` will have one field 62The result will contain an `args` field and a `positionals` field. `args` will have one field for
63for each none positional parameter of your program. The name of the field will be the longest 63each non-positional parameter of your program. The name of the field will be the longest name of the
64name of the parameter. `positionals` be a tuple with one field for each positional parameter. 64parameter. `positionals` will be a tuple with one field for each positional parameter.
65 65
66The fields in `args` and `postionals` are typed. The type is based on the name of the value the 66The fields in `args` and `postionals` are typed. The type is based on the name of the value the
67parameter takes. Since `--number` takes a `usize` the field `res.args.number` has the type `usize`. 67parameter takes. Since `--number` takes a `usize` the field `res.args.number` has the type `usize`.
68 68
69Note that this is only the case because `clap.parsers.default` has a field called `usize` which 69Note that this is only the case because `clap.parsers.default` has a field called `usize` which
70contains a parser that returns `usize`. You can pass in something other than 70contains a parser that returns `usize`. You can pass in something other than `clap.parsers.default`
71`clap.parsers.default` if you want some other mapping. 71if you want some other mapping.
72 72
73```zig 73```zig
74{s} 74{s}
@@ -92,15 +92,13 @@ The `streaming.Clap` is the base of all the other parsers. It's a streaming pars
92{s} 92{s}
93``` 93```
94 94
95Currently, this parser is the only parser that allows an array of `Param` that 95Currently, this parser is the only parser that allows an array of `Param` that is generated at runtime.
96is generated at runtime.
97 96
98### `help` 97### `help`
99 98
100The `help` prints a simple list of all parameters the program can take. It expects the 99`help` prints a simple list of all parameters the program can take. It expects the `Id` to have a
101`Id` to have a `description` method and an `value` method so that it can provide that 100`description` method and an `value` method so that it can provide that in the output. `HelpOptions`
102in the output. `HelpOptions` is passed to `help` to control how the help message is 101is passed to `help` to control how the help message is printed.
103printed.
104 102
105```zig 103```zig
106{s} 104{s}
@@ -117,8 +115,8 @@ $ zig-out/bin/help --help
117 115
118### `usage` 116### `usage`
119 117
120The `usage` prints a small abbreviated version of the help message. It expects the `Id` 118`usage` prints a small abbreviated version of the help message. It expects the `Id` to have a
121to have a `value` method so it can provide that in the output. 119`value` method so it can provide that in the output.
122 120
123```zig 121```zig
124{s} 122{s}