Created
November 1, 2023 18:51
-
-
Save marler8997/aec1f5e552b99fb0c2fa54cb673e9a5d to your computer and use it in GitHub Desktop.
Thing.zig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
fn fatal(comptime fmt: []const u8, args: anytype) noreturn { | |
std.log.err(fmt, args); | |
std.os.exit(0xff); | |
} | |
pub fn main() void { | |
var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
const arena = arena_instance.allocator(); | |
var args = try std.process.argsWithAllocator(arena); | |
_ = args.next(); | |
var filepath: []const u8 = ".env"; | |
while (args.next()) |arg| { | |
if (std.mem.eql(u8, "-f", arg)) { | |
filepath = args.next() orelse fatal( | |
"error: option '-f' requires an argument <envfile>", .{} | |
); | |
} else fatal("error: unknown cmdline argument '{s}'", .{arg}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment