-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.zig
46 lines (37 loc) · 1.02 KB
/
main.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const std = @import("std");
const builtin = @import("builtin");
const App = @import("./app/App.zig");
const args = @import("./app/args.zig");
const utils = @import("./utils.zig");
const fs = std.fs;
const mem = std.mem;
const heap = std.heap;
const os = std.os;
pub const std_options = .{
.log_level = if (builtin.mode == .Debug) .debug else .err,
.logFn = utils.log.logFn,
};
pub fn main() !void {
var config: App.Config = .{ .root = "." };
try args.setConfigFromEnv(&config);
// Returns true if arg has --help
if (try args.setConfig(&config)) {
return;
}
var gpa = heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
try exe(
allocator,
&config,
);
}
fn exe(allocator: mem.Allocator, config: *App.Config) !void {
var app = try App.init(allocator, config);
defer app.deinit();
try app.run();
}
test "app" {
std.debug.print("\n", .{});
var config: App.Config = .{ .root = "." };
try exe(std.testing.allocator, &config);
}