╭ changed ──╮ │src/try.zig│ ╰───────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────╮ │ 8 const evt = hx.event; │ │ 9 const xit = hx.xit; │ │10 const rp = xit.repo; │ │11 +const Page = hx.page.Page; │ │12 │ │13 pub fn main() !void { │ │14 var gpa: std.heap.DebugAllocator(.{}) = .init;│ ╰──────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │35 const cwd_path = try std.process.currentPathAlloc(io, allocator); │ │36 defer allocator.free(cwd_path); │ │37 │ │37 - const server_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "server" }); │ │38 - defer allocator.free(server_path); │ │38 + var page_arena = std.heap.ArenaAllocator.init(allocator); │ │39 + defer page_arena.deinit(); │ │40 │ │40 - // create the admin repo │ │41 - { │ │41 + // create the admin repo and build the Page from it │ │42 + const page: Page = blk: { │ │43 const work_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "server", "admin" });│ │44 defer allocator.free(work_path); │ │45 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │163 │ │164 // consume events into the database │ │165 try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" });│ │165 - } │ │166 │ │167 - // start server │ │167 + break :blk .{ .user_repo = try .init(repo_opts, &page_arena, &repo) }; │ │168 + }; │ │169 + │ │170 + // start the server │ │171 │ │172 var null_writer = std.Io.Writer.Discarding.init(&.{}); │ │173 var environ_map = std.process.Environ.Map.init(allocator); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │174 defer environ_map.deinit(); │ │175 const run_opts = hx.main.RunOpts{ .out = &null_writer.writer, .err = &null_writer.writer, .environ_map = &environ_map };│ │176 + │ │177 + const server_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "server" }); │ │178 + defer allocator.free(server_path); │ │179 + │ │180 + const Runnable = struct { │ │181 + io: std.Io, │ │182 + allocator: std.mem.Allocator, │ │183 + page: *const Page, │ │184 + │ │185 + pub fn run(self: @This()) !void { │ │186 + // launch the TUI │ │187 + try hx.ui.run(self.io, self.allocator, self.page); │ │188 + } │ │189 + }; │ │190 │ │191 try srv.run(.xit, .{}, io, allocator, cwd_path, .{ │ │192 .data_dir = server_path, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │176 - .tui = true, │ │177 - }, run_opts.err); │ │193 + }, run_opts.err, Runnable{ .io = io, .allocator = allocator, .page = &page });│ │194 } │ │195 │ ╰───────────────────────────────────────────────────────────────────────────────────────╯