Added --cmd
This commit is contained in:
parent
e9e3c992cb
commit
4776b84310
1 changed files with 9 additions and 2 deletions
|
|
@ -80,10 +80,17 @@ static class Lox{
|
|||
int main(string[] argv){
|
||||
auto args = new Program("lox")
|
||||
.add(new Argument("path").optional.acceptsFiles)
|
||||
.add(new Option("cmd").name("command"))
|
||||
.parse(argv);
|
||||
try{
|
||||
if(args.arg("path"))
|
||||
Lox.runFile(args.arg("path"));
|
||||
if(args.arg("path") && args.option("command")){
|
||||
stderr.writeln("Cant have both path and --cmd");
|
||||
return 3;
|
||||
}
|
||||
if(auto cmd = args.option("command"))
|
||||
Lox.run(cmd);
|
||||
else if(auto path = args.arg("path"))
|
||||
Lox.runFile(path);
|
||||
else
|
||||
Lox.runPrompt();
|
||||
} catch(MainException rte){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue