add printing of commands to any stream
This commit is contained in:
parent
736277db04
commit
8b67ccc1bf
2 changed files with 27 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
const std = @import("std");
|
||||
const langs = @import("lang.zig");
|
||||
const runners = @import("runner.zig");
|
||||
const printer = @import("printer.zig");
|
||||
|
||||
test "scritcher" {
|
||||
_ = @import("lang.zig");
|
||||
|
@ -52,6 +53,9 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
|||
|
||||
// TODO save the line to scri_file? or should we have a special `push`
|
||||
// to do so?
|
||||
|
||||
// note this is debug
|
||||
try printer.printList(cmds, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
23
src/printer.zig
Normal file
23
src/printer.zig
Normal file
|
@ -0,0 +1,23 @@
|
|||
const langs = @import("lang.zig");
|
||||
|
||||
pub fn printList(list: langs.CommandList, stream: var) !void {
|
||||
for (list.toSlice()) |cmd| {
|
||||
var command = switch (cmd.command) {
|
||||
.Noop => "noop",
|
||||
.Load => "load",
|
||||
.Quicksave => "quicksave",
|
||||
.RunQS => "runqs",
|
||||
|
||||
// TODO rest of commands
|
||||
else => unreachable,
|
||||
};
|
||||
|
||||
try stream.print("{}", command);
|
||||
|
||||
for (cmd.args.toSlice()) |arg| {
|
||||
try stream.print(" {}", arg);
|
||||
}
|
||||
|
||||
try stream.write(";\n");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue