diff options
| author | 2024-10-24 17:47:48 +0200 | |
|---|---|---|
| committer | 2024-10-24 17:47:48 +0200 | |
| commit | 4ec4273a8a3b0ab02f1a7e49e971da8b5a71a034 (patch) | |
| tree | bbd2710a06f228e7e11692494daa9ccaa2a900af | |
| parent | docs: Add subcommand example (diff) | |
| download | zig-clap-4ec4273a8a3b0ab02f1a7e49e971da8b5a71a034.tar.gz zig-clap-4ec4273a8a3b0ab02f1a7e49e971da8b5a71a034.tar.xz zig-clap-4ec4273a8a3b0ab02f1a7e49e971da8b5a71a034.zip | |
fix: Subcommand example comments needs a scroll to be read
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | example/subcommands.zig | 12 |
2 files changed, 12 insertions, 12 deletions
| @@ -208,11 +208,11 @@ pub fn main() !void { | |||
| 208 | .diagnostic = &diag, | 208 | .diagnostic = &diag, |
| 209 | .allocator = gpa, | 209 | .allocator = gpa, |
| 210 | 210 | ||
| 211 | // Terminate the parsing of arguments after parsing the first positional (0 is passed here | 211 | // Terminate the parsing of arguments after parsing the first positional (0 is passed |
| 212 | // because parsed positionals are, like slices and arrays, indexed starting at 0). | 212 | // here because parsed positionals are, like slices and arrays, indexed starting at 0). |
| 213 | // | 213 | // |
| 214 | // This will terminate the parsing after parsing the subcommand enum and leave `iter` not | 214 | // This will terminate the parsing after parsing the subcommand enum and leave `iter` |
| 215 | // fully consumed. It can then be reused to parse the arguments for subcommands | 215 | // not fully consumed. It can then be reused to parse the arguments for subcommands |
| 216 | .terminating_positional = 0, | 216 | .terminating_positional = 0, |
| 217 | }) catch |err| { | 217 | }) catch |err| { |
| 218 | diag.report(std.io.getStdErr().writer(), err) catch {}; | 218 | diag.report(std.io.getStdErr().writer(), err) catch {}; |
| @@ -231,8 +231,8 @@ pub fn main() !void { | |||
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | fn mathMain(gpa: std.mem.Allocator, iter: *std.process.ArgIterator, main_args: MainArgs) !void { | 233 | fn mathMain(gpa: std.mem.Allocator, iter: *std.process.ArgIterator, main_args: MainArgs) !void { |
| 234 | // The parent arguments are not used it, but there are cases where it might be useful, so the | 234 | // The parent arguments are not used it, but there are cases where it might be useful, so |
| 235 | // example shows how to pass the arguments around. | 235 | // the example shows how to pass the arguments around. |
| 236 | _ = main_args; | 236 | _ = main_args; |
| 237 | 237 | ||
| 238 | // The parameters for the subcommand | 238 | // The parameters for the subcommand |
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 | ||
| 59 | fn mathMain(gpa: std.mem.Allocator, iter: *std.process.ArgIterator, main_args: MainArgs) !void { | 59 | fn 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 |