add doRepl func
This commit is contained in:
parent
7e8023a383
commit
fc8dcf4583
1 changed files with 29 additions and 0 deletions
29
src/main.zig
29
src/main.zig
|
@ -7,6 +7,29 @@ test "scritcher" {
|
||||||
_ = @import("runner.zig");
|
_ = @import("runner.zig");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
||||||
|
const scri_path = try (args_it.next(allocator) orelse @panic("expected scri path"));
|
||||||
|
|
||||||
|
// the thing here is that 'load :0' would load the scri_path, since we
|
||||||
|
// now have a 'repl' argument right before it. to counteract that, the
|
||||||
|
// initial repl buffer contains 'load :1' instead.
|
||||||
|
|
||||||
|
var buf = langs.CommandList.init(allocator);
|
||||||
|
defer buf.deinit();
|
||||||
|
|
||||||
|
var loadargs = langs.ArgList.init(allocator);
|
||||||
|
defer loadargs.deinit();
|
||||||
|
|
||||||
|
try loadargs.append(":1");
|
||||||
|
|
||||||
|
try buf.append(langs.Command{
|
||||||
|
.command = .Load,
|
||||||
|
.args = loadargs,
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO the rest
|
||||||
|
}
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
const allocator = std.heap.direct_allocator;
|
const allocator = std.heap.direct_allocator;
|
||||||
|
|
||||||
|
@ -18,9 +41,15 @@ pub fn main() !void {
|
||||||
|
|
||||||
var args_it = std.process.args();
|
var args_it = std.process.args();
|
||||||
|
|
||||||
|
// TODO print help
|
||||||
|
|
||||||
_ = try (args_it.next(allocator) orelse @panic("expected exe name"));
|
_ = try (args_it.next(allocator) orelse @panic("expected exe name"));
|
||||||
const scri_path = try (args_it.next(allocator) orelse @panic("expected scri path"));
|
const scri_path = try (args_it.next(allocator) orelse @panic("expected scri path"));
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, scri_path, "repl")) {
|
||||||
|
return try doRepl(allocator, &args_it);
|
||||||
|
}
|
||||||
|
|
||||||
var file = try std.fs.File.openRead(scri_path);
|
var file = try std.fs.File.openRead(scri_path);
|
||||||
defer file.close();
|
defer file.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue