use commandr

This commit is contained in:
nazrin 2025-05-28 20:08:52 +00:00
parent 658f8f96c1
commit 074fde11ea
3 changed files with 9 additions and 6 deletions

View file

@ -3,6 +3,8 @@ import std.file;
import std.conv;
import std.exception;
import commandr;
import token;
import tokentype;
import scanner;
@ -44,12 +46,11 @@ void runPrompt(){
}
int main(string[] argv){
if(argv.length > 2){
writeln("Usage: jlox [script]");
return 1;
}
if(argv.length == 2)
runFile(argv[1]);
auto args = new Program("lox")
.add(new Argument("path").optional.acceptsFiles)
.parse(argv);
if(args.arg("path"))
runFile(args.arg("path"));
else
runPrompt();
return 0;