diff options
Diffstat (limited to 'src/host/Console.zig')
| -rw-r--r-- | src/host/Console.zig | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/host/Console.zig b/src/host/Console.zig index 9f14830..75da732 100644 --- a/src/host/Console.zig +++ b/src/host/Console.zig @@ -17,6 +17,7 @@ const host_commands = [_][]const u8{ "help", "overlay memory", "overlay sound", "get", "set", "reset", "save", "load", "snapshot", "recording", "marks", "clips", "play session", "record", "stop", "play", "pause", "step", "seek start", "seek end", "diff", "quit", "exit", "overlay timing", "sessions", "timing on", "timing off", "timing frame", "timing work", "timing reset", "timing stats", + "export-session", "import", }; visible: bool = false, @@ -158,7 +159,8 @@ pub fn execute(self: *Console, host: *Host, line: []const u8, now: u64) ![]const if (eq(command, "help")) { self.log("save|load|diff [MARK] snapshot MARK marks | record|play [CLIP] recording CLIP clips | stop | pause"); - self.log("step N (frames) | seek start|end|<ms> | sessions | reset | get|set <field> [<value>] | overlay memory|sound | quit"); + self.log("step N (frames) | seek start|end|<ms> | sessions | play session S [at SECS] | export-session [S] FILE | import FILE"); + self.log("reset | get|set <field> [<value>] | overlay memory|sound | quit"); self.log("timing [on|off|frame|work|reset|stats] | overlay timing"); if (host.forward(self, line, now) == .unknown) self.log("Backtick hides the console. Tab completes."); return &.{}; @@ -290,6 +292,20 @@ pub fn execute(self: *Console, host: *Host, line: []const u8, now: u64) ![]const } else if (eq(command, "sessions")) { if (arg != null) return error.UnexpectedArgument; try self.listSessions(host); + } else if (eq(command, "export-session")) { + const s = &host.sessions; + const first = arg orelse return error.ExpectedFile; + const index = if (rest.len == 0) s.session else std.fmt.parseInt(u64, first, 10) catch return error.InvalidSession; + const path = if (rest.len == 0) first else std.mem.trim(u8, rest, " \t"); + try s.exportSession(index, path); + self.print("Exported session {d} to {s}.", .{ index, path }); + } else if (eq(command, "import")) { + const path = arg orelse return error.ExpectedFile; + if (rest.len != 0) return error.UnexpectedArgument; + const s = &host.sessions; + const first = try s.import(path); + const n = try s.count(.sessions); + self.print("Imported {s} as session {d}..{d}; marks and clips are NAME@{s}.", .{ path, first, n - 1, std.fs.path.basename(path) }); } else if (eq(command, "marks") or eq(command, "clips")) { if (arg != null) return error.UnexpectedArgument; try self.listNamed(host, eq(command, "marks")); @@ -349,7 +365,7 @@ fn listSessions(self: *Console, host: *Host) !void { const d = (m.ended -| m.started) / std.time.ns_per_s; break :blk std.fmt.bufPrint(&end_buf, "{d}:{d:0>2}", .{ d / 60, d % 60 }) catch ""; }; - self.print("{d}: {d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2} builds {d} frames {d} {s}", .{ i, day.year, md.month.numeric(), md.day_index + 1, ds.getHoursIntoDay(), ds.getMinutesIntoHour(), m.stretches, m.frames, end }); + self.print("{d}: {d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2} builds {d} frames {d} {s} {s}", .{ i, day.year, md.month.numeric(), md.day_index + 1, ds.getHoursIntoDay(), ds.getMinutesIntoHour(), m.stretches, m.frames, end, m.from() }); } } |
