╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ try.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
201 while (arg_it.next()) |arg| { 202 if (std.mem.eql(u8, "--cli", arg)) { 203 cli = true; 204 } 205 } 206 207 const server_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "server" }); 208 defer allocator.free(server_path); 209 210 if (cli) { 211 var stdout_writer = std.Io.File.stdout().writer(io, &.{}); 212 var stderr_writer = std.Io.File.stderr().writer(io, &.{}); 213 const run_opts = hx.main.RunOpts{ .out = &stdout_writer.interface, .err = &stderr_writer.interface }; 214 215 const Runnable = struct { 216 io: std.Io, 217 218 pub fn run(self: @This()) !void { 219 std.debug.print( 220 \\ 221 \\connect to the TUI with: 222 \\ ssh -p 8022 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null localhost 223 \\ 224 \\create a git repo and push over SSH: 225 \\ mkdir -p temp-try/client/test 226 \\ cd temp-try/client/test 227 \\ git init 228 \\ echo "hello" > hello.txt 229 \\ git add hello.txt 230 \\ git commit -m "let there be light" 231 \\ GIT_SSH_COMMAND='ssh -p 8022 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' git push localhost:test HEAD:master 232 \\ 233 \\to quit, press enter. 234 \\ 235 , .{}); 236 // portable stdin read via std.Io — equivalent to the 237 // std.posix.read(STDIN_FILENO, ...) that doesn't compile 238 // on windows. 239 var buf: [1]u8 = undefined; 240 var stdin_reader = std.Io.File.stdin().reader(self.io, &buf); 241 _ = stdin_reader.interface.takeByte() catch {}; 242 } 243 }; 244 245 try srv.run(.xit, .{}, io, allocator, cwd_path, .{ 246 .data_dir = server_path, 247 }, run_opts.err, Runnable{ .io = io }); 248 } else { 249 var null_writer = std.Io.Writer.Discarding.init(&.{}); 250 const run_opts = hx.main.RunOpts{ .out = &null_writer.writer, .err = &null_writer.writer }; 251 252 const Runnable = struct { 253 io: std.Io, 254 allocator: std.mem.Allocator, 255 page: *const ui.Page, 256 session: *ui.Session, 257 258 pub fn run(self: @This()) !void { 259 // launch the TUI 260 try hx.ui.run(self.io, self.allocator, self.page, self.session); 261 } 262 }; 263 264 try srv.run(.xit, .{}, io, allocator, cwd_path, .{ 265 .data_dir = server_path, 266 }, run_opts.err, Runnable{ .io = io, .allocator = allocator, .page = &page, .session = &session }); 267 } 268 } 269