diff options
| author | 2020-04-18 16:43:18 +0200 | |
|---|---|---|
| committer | 2020-04-18 16:43:18 +0200 | |
| commit | 0b1dd505dda4c2f3076cf9d074d20666cefa0e20 (patch) | |
| tree | 5b24f351c47e69f1836d7a696d63a71d9081381c /example/usage.zig | |
| parent | Merge pull request #17 from joachimschmidt557/zig-master (diff) | |
| parent | Better readme for usage (diff) | |
| download | zig-clap-0b1dd505dda4c2f3076cf9d074d20666cefa0e20.tar.gz zig-clap-0b1dd505dda4c2f3076cf9d074d20666cefa0e20.tar.xz zig-clap-0b1dd505dda4c2f3076cf9d074d20666cefa0e20.zip | |
Merge branch 'master' into zig-master
Diffstat (limited to 'example/usage.zig')
| -rw-r--r-- | example/usage.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/example/usage.zig b/example/usage.zig new file mode 100644 index 0000000..25e1a34 --- /dev/null +++ b/example/usage.zig | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | const std = @import("std"); | ||
| 2 | const clap = @import("clap"); | ||
| 3 | |||
| 4 | pub fn main() !void { | ||
| 5 | const stderr = std.io.getStdErr().outStream(); | ||
| 6 | |||
| 7 | // clap.usage is a function that can print a simple usage message, given a | ||
| 8 | // slice of Param(Help). There is also a usageEx, which can print a | ||
| 9 | // usage message for any Param, but it is more verbose to call. | ||
| 10 | try clap.usage( | ||
| 11 | stderr, | ||
| 12 | comptime &[_]clap.Param(clap.Help){ | ||
| 13 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, | ||
| 14 | clap.parseParam("-v, --version Output version information and exit.") catch unreachable, | ||
| 15 | clap.parseParam(" --value <N> Output version information and exit.") catch unreachable, | ||
| 16 | }, | ||
| 17 | ); | ||
| 18 | } | ||