From dc1431c20883677f8176033ed2fb8ee4360a1b8e Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Sat, 9 Nov 2019 13:12:34 +0100 Subject: Breaking: OsIterator will now get the exe on init --- clap/args.zig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'clap') 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 { arena: heap.ArenaAllocator, args: process.ArgIterator, - pub fn init(allocator: *mem.Allocator) OsIterator { - return OsIterator{ + /// The executable path (this is the first argument passed to the program) + /// TODO: Is it the right choice for this to be null? Maybe `init` should + /// return an error when we have no exe. + exe_arg: ?[]const u8, + + pub fn init(allocator: *mem.Allocator) Error!OsIterator { + var res = OsIterator{ .arena = heap.ArenaAllocator.init(allocator), .args = process.args(), + .exe_arg = undefined, }; + res.exe_arg = try res.next(); + return res; } pub fn deinit(iter: *OsIterator) void { -- cgit v1.2.3