parent
7cf16f9ffa
commit
c05be26dbd
2 changed files with 16 additions and 8 deletions
10
src/main.zig
10
src/main.zig
|
@ -54,11 +54,9 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if there isn't any commands on the file, we load our default
|
// if there isn't any commands on the file, we load our default
|
||||||
// 'load :1' command
|
// 'load :0' command
|
||||||
|
|
||||||
// TODO load should +1 the index if its on repl
|
|
||||||
var loadargs = langs.ArgList.init(allocator);
|
var loadargs = langs.ArgList.init(allocator);
|
||||||
try loadargs.append(":1");
|
try loadargs.append(":0");
|
||||||
|
|
||||||
try cmds.append(langs.Command{
|
try cmds.append(langs.Command{
|
||||||
.command = .Load,
|
.command = .Load,
|
||||||
|
@ -90,7 +88,7 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: var) !void {
|
||||||
|
|
||||||
var current: langs.Command = undefined;
|
var current: langs.Command = undefined;
|
||||||
|
|
||||||
var runner = runners.Runner.init(allocator);
|
var runner = runners.Runner.init(allocator, true);
|
||||||
defer runner.deinit();
|
defer runner.deinit();
|
||||||
|
|
||||||
// run the load command
|
// run the load command
|
||||||
|
@ -164,7 +162,7 @@ pub fn main() !void {
|
||||||
var lang = langs.Lang.init(allocator);
|
var lang = langs.Lang.init(allocator);
|
||||||
defer lang.deinit();
|
defer lang.deinit();
|
||||||
|
|
||||||
var runner = runners.Runner.init(allocator);
|
var runner = runners.Runner.init(allocator, false);
|
||||||
defer runner.deinit();
|
defer runner.deinit();
|
||||||
|
|
||||||
var args_it = std.process.args();
|
var args_it = std.process.args();
|
||||||
|
|
|
@ -19,11 +19,17 @@ pub const RunError = error{
|
||||||
|
|
||||||
pub const Runner = struct {
|
pub const Runner = struct {
|
||||||
allocator: *std.mem.Allocator,
|
allocator: *std.mem.Allocator,
|
||||||
|
|
||||||
|
/// The currently opened image in the runner
|
||||||
image: ?*Image = null,
|
image: ?*Image = null,
|
||||||
|
|
||||||
pub fn init(allocator: *std.mem.Allocator) Runner {
|
/// If the runner is in REPL mode
|
||||||
|
repl: bool = false,
|
||||||
|
|
||||||
|
pub fn init(allocator: *std.mem.Allocator, repl: bool) Runner {
|
||||||
return Runner{
|
return Runner{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
|
.repl = repl,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +47,11 @@ pub const Runner = struct {
|
||||||
fn resolveArg(self: *Runner, load_path: []const u8) ![]const u8 {
|
fn resolveArg(self: *Runner, load_path: []const u8) ![]const u8 {
|
||||||
if (load_path[0] == ':') {
|
if (load_path[0] == ':') {
|
||||||
// parse the index from 1 to end
|
// parse the index from 1 to end
|
||||||
const index = try std.fmt.parseInt(usize, load_path[1..], 10);
|
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;
|
||||||
|
|
||||||
var args_it = std.process.args();
|
var args_it = std.process.args();
|
||||||
_ = args_it.skip();
|
_ = args_it.skip();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue