summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2025-07-22 10:54:19 +0200
committerGravatar Jimmi Holst Christensen2025-07-22 10:54:19 +0200
commit0356f53d5bc46011efc6b6ffbfe0b202466d7b4f (patch)
tree98efe75192b2aca9f293ec0ce03c78f20a6e1ec3 /README.md
parentfeat: Add `clap.helpToFile` (diff)
downloadzig-clap-0356f53d5bc46011efc6b6ffbfe0b202466d7b4f.tar.gz
zig-clap-0356f53d5bc46011efc6b6ffbfe0b202466d7b4f.tar.xz
zig-clap-0356f53d5bc46011efc6b6ffbfe0b202466d7b4f.zip
feat: Add `clap.usageToFile`
The code for printing usage became quite verbose after writegate. Writing usage 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 'README.md')
-rw-r--r--README.md12
1 files changed, 4 insertions, 8 deletions
diff --git a/README.md b/README.md
index 6a1435f..b9fbda7 100644
--- a/README.md
+++ b/README.md
@@ -404,14 +404,10 @@ pub fn main() !void {
404 }); 404 });
405 defer res.deinit(); 405 defer res.deinit();
406 406
407 // `clap.usage` is a function that can print a simple help message. It can print any `Param` 407 // `clap.usageToFile` is a function that can print a simple usage string. It can print any
408 // where `Id` has a `value` method (`Param(Help)` is one such parameter). 408 // `Param` where `Id` has a `value` method (`Param(Help)` is one such parameter).
409 if (res.args.help != 0) { 409 if (res.args.help != 0)
410 var buf: [1024]u8 = undefined; 410 return clap.usage(.stdout(), clap.Help, &params);
411 var stderr = std.fs.File.stderr().writer(&buf);
412 try clap.usage(&stderr.interface, clap.Help, &params);
413 return stderr.interface.flush();
414 }
415} 411}
416 412
417const clap = @import("clap"); 413const clap = @import("clap");