diff options
| author | 2019-11-09 13:12:34 +0100 | |
|---|---|---|
| committer | 2019-11-09 13:12:34 +0100 | |
| commit | dc1431c20883677f8176033ed2fb8ee4360a1b8e (patch) | |
| tree | 179651a820cfcc031f597091620d8e381a6e26cb /clap/args.zig | |
| parent | fmt, mv src/ clap/ and run fmt on build (diff) | |
| download | zig-clap-dc1431c20883677f8176033ed2fb8ee4360a1b8e.tar.gz zig-clap-dc1431c20883677f8176033ed2fb8ee4360a1b8e.tar.xz zig-clap-dc1431c20883677f8176033ed2fb8ee4360a1b8e.zip | |
Breaking: OsIterator will now get the exe on init
Diffstat (limited to 'clap/args.zig')
| -rw-r--r-- | clap/args.zig | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/clap/args.zig b/clap/args.zig index 4234ada..b699438 100644 --- a/clap/args.zig +++ b/clap/args.zig | |||
| @@ -50,11 +50,19 @@ pub const OsIterator = struct { | |||
| 50 | arena: heap.ArenaAllocator, | 50 | arena: heap.ArenaAllocator, |
| 51 | args: process.ArgIterator, | 51 | args: process.ArgIterator, |
| 52 | 52 | ||
| 53 | pub fn init(allocator: *mem.Allocator) OsIterator { | 53 | /// The executable path (this is the first argument passed to the program) |
| 54 | return OsIterator{ | 54 | /// TODO: Is it the right choice for this to be null? Maybe `init` should |
| 55 | /// return an error when we have no exe. | ||
| 56 | exe_arg: ?[]const u8, | ||
| 57 | |||
| 58 | pub fn init(allocator: *mem.Allocator) Error!OsIterator { | ||
| 59 | var res = OsIterator{ | ||
| 55 | .arena = heap.ArenaAllocator.init(allocator), | 60 | .arena = heap.ArenaAllocator.init(allocator), |
| 56 | .args = process.args(), | 61 | .args = process.args(), |
| 62 | .exe_arg = undefined, | ||
| 57 | }; | 63 | }; |
| 64 | res.exe_arg = try res.next(); | ||
| 65 | return res; | ||
| 58 | } | 66 | } |
| 59 | 67 | ||
| 60 | pub fn deinit(iter: *OsIterator) void { | 68 | pub fn deinit(iter: *OsIterator) void { |