╭ changed ────╮ │src/serve.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────╮ │2 const xit = @import("xit"); │ │3 const rp = xit.repo; │ │4 const hash = xit.hash; │ │5 +const ui = @import("./ui.zig");│ │6 │ │7 pub const Options = struct { │ │8 http_listen: []const u8, │ ╰──────────────────────────────────╯ ╭──────────────────────────────────╮ │ 9 ssh_listen: ?[]const u8, │ │10 data_dir: []const u8, │ │11 + ui: bool, │ │12 }; │ │13 │ │14 const ListenAddress = struct {│ ╰──────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │54 defer tasks.cancel(io); │ │55 │ │56 runHttpListener(repo_kind, any_repo_opts, io, allocator, repo_root_path, &http_server, &tasks, err);│ │57 + │ │58 + if (options.ui) { │ │59 + runTui(io, allocator, &tasks, err); │ │60 + } │ │61 │ │62 // create ssh listener │ │63 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │ 80 try tasks.await(io); │ │ 81 } │ │ 82 │ │ 83 +fn runTui( │ │ 84 + io: std.Io, │ │ 85 + allocator: std.mem.Allocator, │ │ 86 + tasks: *std.Io.Group, │ │ 87 + err: *std.Io.Writer, │ │ 88 +) void { │ │ 89 + const TuiTask = struct { │ │ 90 + io: std.Io, │ │ 91 + allocator: std.mem.Allocator, │ │ 92 + err: *std.Io.Writer, │ │ 93 + │ │ 94 + fn run(ctx: @This()) void { │ │ 95 + ui.run(ctx.io, ctx.allocator) catch |ui_err| { │ │ 96 + logError(ctx.err, "ui failed: {s}\n", .{@errorName(ui_err)});│ │ 97 + }; │ │ 98 + } │ │ 99 + }; │ │100 + │ │101 + tasks.async(io, TuiTask.run, .{TuiTask{ │ │102 + .io = io, │ │103 + .allocator = allocator, │ │104 + .err = err, │ │105 + }}); │ │106 +} │ │107 + │ │108 fn runHttpListener( │ │109 comptime repo_kind: rp.RepoKind, │ │110 comptime any_repo_opts: rp.AnyRepoOpts(repo_kind), │ ╰──────────────────────────────────────────────────────────────────────────────────╯