diff options
| author | 2025-07-22 10:49:49 +0200 | |
|---|---|---|
| committer | 2025-07-22 10:49:49 +0200 | |
| commit | 1c8cc16b660d8933c48b1f8c5321542985c92c04 (patch) | |
| tree | 16260ac3cbc89cadefbb713fc554289032b6ed2c /README.md | |
| parent | feat: Add `Diagnostic.reportToFile` (diff) | |
| download | zig-clap-1c8cc16b660d8933c48b1f8c5321542985c92c04.tar.gz zig-clap-1c8cc16b660d8933c48b1f8c5321542985c92c04.tar.xz zig-clap-1c8cc16b660d8933c48b1f8c5321542985c92c04.zip | |
feat: Add `clap.helpToFile`
The code for printing help became quite verbose after writegate. Writing
help to a file like stdout and stderr is very common, so this wrapper
provides a default, buffered way to report to a file.
Diffstat (limited to '')
| -rw-r--r-- | README.md | 8 |
1 files changed, 2 insertions, 6 deletions
| @@ -365,12 +365,8 @@ pub fn main() !void { | |||
| 365 | // where `Id` has a `description` and `value` method (`Param(Help)` is one such parameter). | 365 | // where `Id` has a `description` and `value` method (`Param(Help)` is one such parameter). |
| 366 | // The last argument contains options as to how `help` should print those parameters. Using | 366 | // The last argument contains options as to how `help` should print those parameters. Using |
| 367 | // `.{}` means the default options. | 367 | // `.{}` means the default options. |
| 368 | if (res.args.help != 0) { | 368 | if (res.args.help != 0) |
| 369 | var buf: [1024]u8 = undefined; | 369 | return clap.helpToFile(.stderr(), clap.Help, ¶ms, .{}); |
| 370 | var stderr = std.fs.File.stderr().writer(&buf); | ||
| 371 | try clap.help(&stderr.interface, clap.Help, ¶ms, .{}); | ||
| 372 | return stderr.interface.flush(); | ||
| 373 | } | ||
| 374 | } | 370 | } |
| 375 | 371 | ||
| 376 | const clap = @import("clap"); | 372 | const clap = @import("clap"); |