summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md43
1 files changed, 43 insertions, 0 deletions
diff --git a/README.md b/README.md
index 0555a0f..47c028d 100644
--- a/README.md
+++ b/README.md
@@ -232,3 +232,46 @@ The `helpEx` is the generic version of `help`. It can print a help message for a
232 232
233The `helpFull` is even more generic, allowing the functions that get the help and value strings 233The `helpFull` is even more generic, allowing the functions that get the help and value strings
234to return errors and take a context as a parameter. 234to return errors and take a context as a parameter.
235
236### `usage`
237
238The `usage`, `usageEx` and `usageFull` are functions for printing a simple list of all parameters the
239program can take.
240
241```zig
242const std = @import("std");
243const clap = @import("clap");
244
245pub fn main() !void {
246 const stderr_file = try std.io.getStdErr();
247 var stderr_out_stream = stderr_file.outStream();
248 const stderr = &stderr_out_stream.stream;
249
250 // clap.usage is a function that can print a simple usage message, given a
251 // slice of Param(Help). There is also a usageEx, which can print a
252 // usage message for any Param, but it is more verbose to call.
253 try clap.usage(
254 stderr,
255 comptime [_]clap.Param(clap.Help){
256 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable,
257 clap.parseParam("-v, --version Output version information and exit.") catch unreachable,
258 clap.parseParam(" --value <N> Output version information and exit.") catch unreachable,
259 },
260 );
261}
262
263```
264
265```
266[-hv] [--value <N>]
267```
268
269The `usage` functions are the simplest to call. It only takes an `OutStream` and a slice of
270`Param(Help)`.
271
272The `usageEx` is the generic version of `usage`. It can print a usage message for any
273`Param` give that the caller provides functions for getting the usage and value strings.
274
275The `usageFull` is even more generic, allowing the functions that get the usage and value strings
276to return errors and take a context as a parameter.
277