diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 10 |
1 files changed, 6 insertions, 4 deletions
| @@ -108,6 +108,7 @@ const std = @import("std"); | |||
| 108 | 108 | ||
| 109 | const debug = std.debug; | 109 | const debug = std.debug; |
| 110 | const io = std.io; | 110 | const io = std.io; |
| 111 | const process = std.process; | ||
| 111 | 112 | ||
| 112 | pub fn main() !void { | 113 | pub fn main() !void { |
| 113 | const allocator = std.heap.page_allocator; | 114 | const allocator = std.heap.page_allocator; |
| @@ -126,16 +127,17 @@ pub fn main() !void { | |||
| 126 | .{ .id = 'f', .takes_value = .one }, | 127 | .{ .id = 'f', .takes_value = .one }, |
| 127 | }; | 128 | }; |
| 128 | 129 | ||
| 129 | // We then initialize an argument iterator. We will use the OsIterator as it nicely | 130 | var iter = try process.ArgIterator.initWithAllocator(allocator); |
| 130 | // wraps iterating over arguments the most efficient way on each os. | ||
| 131 | var iter = try clap.args.OsIterator.init(allocator); | ||
| 132 | defer iter.deinit(); | 131 | defer iter.deinit(); |
| 133 | 132 | ||
| 133 | // Skip exe argument | ||
| 134 | _ = iter.next(); | ||
| 135 | |||
| 134 | // Initalize our diagnostics, which can be used for reporting useful errors. | 136 | // Initalize our diagnostics, which can be used for reporting useful errors. |
| 135 | // This is optional. You can also leave the `diagnostic` field unset if you | 137 | // This is optional. You can also leave the `diagnostic` field unset if you |
| 136 | // don't care about the extra information `Diagnostic` provides. | 138 | // don't care about the extra information `Diagnostic` provides. |
| 137 | var diag = clap.Diagnostic{}; | 139 | var diag = clap.Diagnostic{}; |
| 138 | var parser = clap.StreamingClap(u8, clap.args.OsIterator){ | 140 | var parser = clap.StreamingClap(u8, process.ArgIterator){ |
| 139 | .params = ¶ms, | 141 | .params = ¶ms, |
| 140 | .iter = &iter, | 142 | .iter = &iter, |
| 141 | .diagnostic = &diag, | 143 | .diagnostic = &diag, |