Compare commits

..

No commits in common. "c78ca9dd5b81e23bfbeebd7c25e3732d16532236" and "aeb76fe6c0b97f342566a05a3c2e807518e298de" have entirely different histories.

2 changed files with 13 additions and 15 deletions

View file

@ -79,7 +79,7 @@ pub fn temporaryName(allocator: *std.mem.Allocator) ![]u8 {
var nam = try allocator.alloc(u8, template.len); var nam = try allocator.alloc(u8, template.len);
std.mem.copy(u8, nam, template); std.mem.copy(u8, nam, template);
const seed = @truncate(u64, @bitCast(u128, std.time.nanoTimestamp())); const seed = @bitCast(u64, std.time.timestamp());
var r = std.rand.DefaultPrng.init(seed); var r = std.rand.DefaultPrng.init(seed);
var fill = nam[template_start.len..nam.len]; var fill = nam[template_start.len..nam.len];

View file

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