summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md42
1 files changed, 4 insertions, 38 deletions
diff --git a/README.md b/README.md
index e9d1709..2bc86a6 100644
--- a/README.md
+++ b/README.md
@@ -110,7 +110,7 @@ Ofc, this limits you to use only parameters that are comptime known.
110 110
111### `help` 111### `help`
112 112
113The `help` and `helpEx` are functions for printing a simple list of all parameters the 113The `help`, `helpEx` and `helpFull` are functions for printing a simple list of all parameters the
114program can take. 114program can take.
115 115
116```rust 116```rust
@@ -142,41 +142,7 @@ The `help` function is the simplest to call. It only takes an `OutStream` and a
142`Param([]const u8)`. This function assumes that the id of each parameter is the help message. 142`Param([]const u8)`. This function assumes that the id of each parameter is the help message.
143 143
144The `helpEx` is the generic version of `help`. It can print a help message for any 144The `helpEx` is the generic version of `help`. It can print a help message for any
145`Param`, but requires some extra arguments to work. 145`Param` give that the caller provides functions for getting the help and value strings.
146 146
147```rust 147The `helpFull` is even more generic, allowing the functions that get the help and value strings
148fn getHelp(_: void, param: clap.Param(u8)) error{}![]const u8 { 148to return errors and take a context as a parameter.
149 return switch (param.id) {
150 'h' => "Display this help and exit.",
151 'v' => "Output version information and exit.",
152 else => unreachable,
153 };
154}
155
156fn getValue(_: void, param: clap.Param(u8)) error{}![]const u8 {
157 return "";
158}
159
160const stderr_file = try std.io.getStdErr();
161var stderr_out_stream = stderr_file.outStream();
162const stderr = &stderr_out_stream.stream;
163
164try stderr.print("\n");
165try clap.helpEx(
166 stderr,
167 u8,
168 []clap.Param(u8){
169 clap.Param(u8).flag('h', clap.Names.prefix("help")),
170 clap.Param(u8).flag('v', clap.Names.prefix("version")),
171 },
172 error{},
173 {},
174 getHelp,
175 getValue,
176);
177```
178
179```
180 -h, --help Display this help and exit.
181 -v, --version Output version information and exit.
182```