diff --git a/src/runner.zig b/src/runner.zig index 6b9f478..234e59e 100644 --- a/src/runner.zig +++ b/src/runner.zig @@ -49,20 +49,22 @@ pub const Runner = struct { // parse the index from 1 to end var index = try std.fmt.parseInt(usize, load_path[1..], 10); - // don't care about the 'repl' being prepended when we're in repl - if (self.repl) index += 1; + // if it isn't in the repl, args look like this: + // 'scritcher ./script ./image' + // if it is, it looks like this + // 'scritcher repl ./script ./image' - var args_it = std.process.args(); - _ = args_it.skip(); + // ':0' should ALWAYS point to the image. + if (self.repl) index += 3 else index += 2; - var i: usize = 0; - while (i <= index) : (i += 1) { - _ = args_it.skip(); + var args = try std.process.argsAlloc(self.allocator); + defer std.process.argsFree(self.allocator, args); + std.debug.warn("ARGS!! {} \n", .{args.len}); + for (args) |arg, idx| { + std.debug.warn("arg{} = {}\n", .{ idx, arg }); } - - const arg = try (args_it.next(self.allocator) orelse @panic("expected argument")); - - return arg; + std.debug.warn("fetch arg idx={}, val={}\n", .{ index, args[index] }); + return args[index]; } else { return load_path; } @@ -90,7 +92,7 @@ pub const Runner = struct { // krita/gimp and make it export a bmp and while in the program you can // apply filters, etc. if (!std.mem.endsWith(u8, load_path, ".bmp") and !std.mem.endsWith(u8, load_path, ".ppm")) { - std.debug.warn("Only BMP files are allowed to be loaded.\n", .{}); + std.debug.warn("Only BMP files are allowed to be loaded. Got path '{}'\n", .{load_path}); return RunError.NoBMP; }