summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2020-04-18 16:43:18 +0200
committerGravatar Jimmi Holst Christensen2020-04-18 16:43:18 +0200
commit0b1dd505dda4c2f3076cf9d074d20666cefa0e20 (patch)
tree5b24f351c47e69f1836d7a696d63a71d9081381c /README.md
parentMerge pull request #17 from joachimschmidt557/zig-master (diff)
parentBetter readme for usage (diff)
downloadzig-clap-0b1dd505dda4c2f3076cf9d074d20666cefa0e20.tar.gz
zig-clap-0b1dd505dda4c2f3076cf9d074d20666cefa0e20.tar.xz
zig-clap-0b1dd505dda4c2f3076cf9d074d20666cefa0e20.zip
Merge branch 'master' into zig-master
Diffstat (limited to 'README.md')
-rw-r--r--README.md36
1 files changed, 36 insertions, 0 deletions
diff --git a/README.md b/README.md
index 642856b..2b38281 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,10 @@
2 2
3A simple and easy to use command line argument parser library for Zig. 3A simple and easy to use command line argument parser library for Zig.
4 4
5Looking for a version that works with `zig master`? The `zig-master` branch has
6you covered. It is maintained by people who live at head (not me) and is merged
7into master on every `zig` release.
8
5## Features 9## Features
6 10
7* Short arguments `-a` 11* Short arguments `-a`
@@ -231,3 +235,35 @@ The `helpEx` is the generic version of `help`. It can print a help message for a
231 235
232The `helpFull` is even more generic, allowing the functions that get the help and value strings 236The `helpFull` is even more generic, allowing the functions that get the help and value strings
233to return errors and take a context as a parameter. 237to return errors and take a context as a parameter.
238
239### `usage`
240
241The `usage`, `usageEx` and `usageFull` are functions for printing a small abbreviated version
242of the help message.
243
244```zig
245const std = @import("std");
246const clap = @import("clap");
247
248pub fn main() !void {
249 const stderr = std.io.getStdErr().outStream();
250
251 // clap.usage is a function that can print a simple usage message, given a
252 // slice of Param(Help). There is also a usageEx, which can print a
253 // usage message for any Param, but it is more verbose to call.
254 try clap.usage(
255 stderr,
256 comptime &[_]clap.Param(clap.Help){
257 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable,
258 clap.parseParam("-v, --version Output version information and exit.") catch unreachable,
259 clap.parseParam(" --value <N> Output version information and exit.") catch unreachable,
260 },
261 );
262}
263
264```
265
266```
267[-hv] [--value <N>]
268```
269