use commandr
This commit is contained in:
parent
658f8f96c1
commit
074fde11ea
3 changed files with 9 additions and 6 deletions
1
dub.sdl
1
dub.sdl
|
|
@ -3,4 +3,5 @@ description "A minimal D application."
|
|||
authors "tanya"
|
||||
copyright "Copyright © 2025, tanya"
|
||||
license "MPL-2.0"
|
||||
dependency "commandr" version="~>1.1.0"
|
||||
dependency "taggedalgebraic" version="~>0.11.23"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"fileVersion": 1,
|
||||
"versions": {
|
||||
"commandr": "1.1.0",
|
||||
"taggedalgebraic": "0.11.23"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
src/main.d
13
src/main.d
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue