this repo has no description
1const std = @import("std");
2const builtin = @import("builtin");
3
4const log = @import("log.zig");
5
6const Allocator = std.mem.Allocator;
7const Server = @import("Server.zig");
8
9const assert = std.debug.assert;
10
11pub const std_options: std.Options = .{
12 .log_level = .debug,
13};
14
15pub fn main() !void {
16 log.init();
17 var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
18 const gpa, const is_debug = gpa: {
19 break :gpa switch (builtin.mode) {
20 .Debug, .ReleaseSafe => .{ debug_allocator.allocator(), true },
21 .ReleaseFast, .ReleaseSmall => .{ std.heap.smp_allocator, false },
22 };
23 };
24 defer if (is_debug) {
25 _ = debug_allocator.deinit();
26 };
27
28 var opts: Server.Options = .{};
29 var args = std.process.args();
30 while (args.next()) |arg| {
31 if (std.mem.eql(u8, arg, "--hostname")) {
32 opts.hostname = args.next() orelse return error.InvalidArgs;
33 continue;
34 }
35 if (std.mem.eql(u8, arg, "--irc-port")) {
36 const port = args.next() orelse return error.InvalidArgs;
37 opts.irc_port = try std.fmt.parseUnsigned(u16, port, 10);
38 continue;
39 }
40 if (std.mem.eql(u8, arg, "--http-port")) {
41 const port = args.next() orelse return error.InvalidArgs;
42 opts.http_port = try std.fmt.parseUnsigned(u16, port, 10);
43 continue;
44 }
45 if (std.mem.eql(u8, arg, "--auth")) {
46 const auth = args.next() orelse return error.InvalidArgs;
47 if (std.mem.eql(u8, auth, "none")) {
48 opts.auth = .none;
49 } else if (std.mem.eql(u8, auth, "github")) {
50 opts.auth = .github;
51 } else if (std.mem.eql(u8, auth, "atproto")) {
52 opts.auth = .atproto;
53 }
54 continue;
55 }
56 if (std.mem.eql(u8, arg, "--db")) {
57 opts.db_path = args.next() orelse return error.InvalidArgs;
58 continue;
59 }
60 }
61 var server: Server = undefined;
62 try server.init(gpa, opts);
63 defer server.deinit();
64
65 try server.loop.run(.until_done);
66}
67
68test {
69 _ = @import("queue.zig");
70 _ = @import("sanitize.zig");
71 _ = @import("Server.zig");
72}