2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-25 16:27:11 -07:00

Added support for run arguments

This commit is contained in:
Erik C. Thauvin 2023-08-13 16:45:02 -07:00
parent cdaea733b2
commit 061a194322
2 changed files with 19 additions and 1 deletions

View file

@ -22,6 +22,6 @@ public class RunHelp implements CommandHelp {
return StringUtils.replace("""
Runs the project.
Usage : ${topic}""", "${topic}", topic);
Usage : ${topic} [--args=ARGUMENT...]""", "${topic}", topic);
}
}

View file

@ -8,6 +8,7 @@ import rife.bld.BaseProject;
import rife.tools.FileUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -35,6 +36,7 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
}
args.add(mainClass());
args.addAll(runOptions());
System.out.println(args);
return args;
}
@ -52,6 +54,22 @@ public class RunOperation extends AbstractProcessOperation<RunOperation> {
if (project.usesRife2Agent()) {
operation.javaOptions().javaAgent(project.getRife2AgentFile());
}
// parse the run arguments if any
var args = project.arguments();
while (!args.isEmpty()) {
var arg = args.get(0);
if (arg.startsWith("-")) {
args.remove(0);
if (arg.startsWith("--args=")) {
var runArgs = arg.substring(7);
if (!runArgs.isBlank()) {
runOptions_.addAll(0, Arrays.asList(runArgs.split(" ")));
}
}
}
}
return operation;
}