diff options
| author | 2022-01-31 17:11:15 +0100 | |
|---|---|---|
| committer | 2022-01-31 17:11:15 +0100 | |
| commit | 7188a9fc85f6aa0f71a4cb7966f8b0a044f29e02 (patch) | |
| tree | 0363b15fb5393c7ca46f60325eee93c13f9c76f7 /example/simple-ex.zig | |
| parent | Relicense to MIT (diff) | |
| download | zig-clap-7188a9fc85f6aa0f71a4cb7966f8b0a044f29e02.tar.gz zig-clap-7188a9fc85f6aa0f71a4cb7966f8b0a044f29e02.tar.xz zig-clap-7188a9fc85f6aa0f71a4cb7966f8b0a044f29e02.zip | |
Refactor the ArgIterator interface
They now follow the interface provided by the standard library. This now
means that we no longer needs `args.OsIterator` as that the one from
`std` can now be used directly.
Also remove `args.ShellIterator` as a simular iterator exists in `std`
called `ArgIteratorGeneral`.
Diffstat (limited to '')
| -rw-r--r-- | example/simple-ex.zig | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/example/simple-ex.zig b/example/simple-ex.zig index 5653fd1..d2dc77e 100644 --- a/example/simple-ex.zig +++ b/example/simple-ex.zig | |||
| @@ -3,6 +3,7 @@ const std = @import("std"); | |||
| 3 | 3 | ||
| 4 | const debug = std.debug; | 4 | const debug = std.debug; |
| 5 | const io = std.io; | 5 | const io = std.io; |
| 6 | const process = std.process; | ||
| 6 | 7 | ||
| 7 | pub fn main() !void { | 8 | pub fn main() !void { |
| 8 | const allocator = std.heap.page_allocator; | 9 | const allocator = std.heap.page_allocator; |
| @@ -16,11 +17,12 @@ pub fn main() !void { | |||
| 16 | clap.parseParam("<POS>...") catch unreachable, | 17 | clap.parseParam("<POS>...") catch unreachable, |
| 17 | }; | 18 | }; |
| 18 | 19 | ||
| 19 | // We then initialize an argument iterator. We will use the OsIterator as it nicely | 20 | var iter = try process.ArgIterator.initWithAllocator(allocator); |
| 20 | // wraps iterating over arguments the most efficient way on each os. | ||
| 21 | var iter = try clap.args.OsIterator.init(allocator); | ||
| 22 | defer iter.deinit(); | 21 | defer iter.deinit(); |
| 23 | 22 | ||
| 23 | // Skip exe argument | ||
| 24 | _ = iter.next(); | ||
| 25 | |||
| 24 | // Initalize our diagnostics, which can be used for reporting useful errors. | 26 | // Initalize our diagnostics, which can be used for reporting useful errors. |
| 25 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't | 27 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't |
| 26 | // care about the extra information `Diagnostics` provides. | 28 | // care about the extra information `Diagnostics` provides. |