Allow tool execution with argument
This commit is contained in:
parent
09e2845cea
commit
084cdd0d3a
@ -29,16 +29,28 @@ public final class ToolsRunner {
|
|||||||
File toolsFolder = new File(ToolsConstants.TOOLS_SOURCE_ROOT);
|
File toolsFolder = new File(ToolsConstants.TOOLS_SOURCE_ROOT);
|
||||||
Map<String, ToolTask> tasks = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
Map<String, ToolTask> tasks = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
collectTasksInDirectory(toolsFolder, tasks);
|
collectTasksInDirectory(toolsFolder, tasks);
|
||||||
listAllTasks(tasks);
|
|
||||||
|
|
||||||
// Prompt user for task and handle input
|
String inputTask;
|
||||||
System.out.println("Please enter the task to run:");
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
String inputTask = scanner.nextLine();
|
boolean interactive = true;
|
||||||
ToolTask task = tasks.get(inputTask);
|
|
||||||
|
if(args == null || args.length == 0) {
|
||||||
|
listAllTasks(tasks);
|
||||||
|
// Prompt user for task and handle input
|
||||||
|
System.out.println("Please enter the task to run:");
|
||||||
|
inputTask = scanner.nextLine();
|
||||||
|
} else {
|
||||||
|
interactive = false;
|
||||||
|
inputTask = args[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTask task = tasks.get(inputTask);
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
task.execute(scanner);
|
if(interactive) {
|
||||||
|
task.execute(scanner);
|
||||||
|
} else {
|
||||||
|
task.execute(null);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Unknown task");
|
System.out.println("Unknown task");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,11 @@ public class PermissionsListWriter implements ToolTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Scanner scanner) {
|
public void execute(Scanner scanner) {
|
||||||
|
if(scanner == null) {
|
||||||
|
generateAndWriteFile();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Ask if result should be written to file
|
// Ask if result should be written to file
|
||||||
System.out.println("Include description? [Enter 'n' for no]");
|
System.out.println("Include description? [Enter 'n' for no]");
|
||||||
boolean includeDescription = !matches("n", scanner);
|
boolean includeDescription = !matches("n", scanner);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user