summaryrefslogtreecommitdiff
path: root/example/subcommands.zig
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2024-10-24 17:47:48 +0200
committerGravatar Jimmi Holst Christensen2024-10-24 17:47:48 +0200
commit4ec4273a8a3b0ab02f1a7e49e971da8b5a71a034 (patch)
treebbd2710a06f228e7e11692494daa9ccaa2a900af /example/subcommands.zig
parentdocs: Add subcommand example (diff)
downloadzig-clap-4ec4273a8a3b0ab02f1a7e49e971da8b5a71a034.tar.gz
zig-clap-4ec4273a8a3b0ab02f1a7e49e971da8b5a71a034.tar.xz
zig-clap-4ec4273a8a3b0ab02f1a7e49e971da8b5a71a034.zip
fix: Subcommand example comments needs a scroll to be read
Diffstat (limited to 'example/subcommands.zig')
-rw-r--r--example/subcommands.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/example/subcommands.zig b/example/subcommands.zig
index 531a4d6..fcd4fee 100644
--- a/example/subcommands.zig
+++ b/example/subcommands.zig
@@ -34,11 +34,11 @@ pub fn main() !void {
34 .diagnostic = &diag, 34 .diagnostic = &diag,
35 .allocator = gpa, 35 .allocator = gpa,
36 36
37 // Terminate the parsing of arguments after parsing the first positional (0 is passed here 37 // Terminate the parsing of arguments after parsing the first positional (0 is passed
38 // because parsed positionals are, like slices and arrays, indexed starting at 0). 38 // here because parsed positionals are, like slices and arrays, indexed starting at 0).
39 // 39 //
40 // This will terminate the parsing after parsing the subcommand enum and leave `iter` not 40 // This will terminate the parsing after parsing the subcommand enum and leave `iter`
41 // fully consumed. It can then be reused to parse the arguments for subcommands 41 // not fully consumed. It can then be reused to parse the arguments for subcommands
42 .terminating_positional = 0, 42 .terminating_positional = 0,
43 }) catch |err| { 43 }) catch |err| {
44 diag.report(std.io.getStdErr().writer(), err) catch {}; 44 diag.report(std.io.getStdErr().writer(), err) catch {};
@@ -57,8 +57,8 @@ pub fn main() !void {
57} 57}
58 58
59fn mathMain(gpa: std.mem.Allocator, iter: *std.process.ArgIterator, main_args: MainArgs) !void { 59fn mathMain(gpa: std.mem.Allocator, iter: *std.process.ArgIterator, main_args: MainArgs) !void {
60 // The parent arguments are not used it, but there are cases where it might be useful, so the 60 // The parent arguments are not used it, but there are cases where it might be useful, so
61 // example shows how to pass the arguments around. 61 // the example shows how to pass the arguments around.
62 _ = main_args; 62 _ = main_args;
63 63
64 // The parameters for the subcommand 64 // The parameters for the subcommand