add debug flag to runCommands

This commit is contained in:
Luna 2019-07-08 13:13:03 -03:00
parent 41a8b18d66
commit 87459939cf
2 changed files with 12 additions and 7 deletions

View file

@ -302,12 +302,16 @@ fn print_usage() !void {
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.c_allocator);
defer arena.deinit();
const allocator = &arena.allocator;
var lang = langs.Lang.init(allocator);
var runner = runners.Runner.init(allocator);
//defer lang.deinit();
var runner = runners.Runner.init(allocator);
//defer runner.deinit();
var args_it = std.process.args();
const exe_name = try (args_it.next(allocator) orelse @panic("expected exe name"));
@ -326,11 +330,7 @@ pub fn main() !void {
_ = try file.read(data);
var cmds = try lang.parse(data);
try runner.runCommands(cmds);
var it = cmds.iterator();
while (it.next()) |cmd| {
cmd.print();
}
try runner.runCommands(cmds, true);
}
pub fn oldMain() !void {

View file

@ -20,10 +20,15 @@ pub const Runner = struct {
};
}
pub fn runCommands(self: *Runner, cmds: lang.CommandList) !void {
pub fn runCommands(
self: *Runner,
cmds: lang.CommandList,
debug_flag: bool,
) !void {
var it = cmds.iterator();
while (it.next()) |cmd| {
if (debug_flag) cmd.print();
try self.runCommand(cmd);
}
}